CakePHP2.0.5のakeDC search pluginで検索に使用した条件を検索結果ページに表示したい!

例:あなたは「アメリカ」で検索しました
と検索結果ページに表示したいです。
以下のコードを記述したのですが、
MoviesController.phpで
public function results() {
$country_cond[] = array();
foreach ($this->request->data["Movie"]["country_id"] as $id) {
$country_cond[] = $id;
}
$country_list = $this->Movie->Country->find('list', Array('conditions' => Array('Country.id' => $country_cond)));

$this->set('movies', $this->paginate('Movie'));
$this->set('country_list', $country_list);
}
/View/Movies/results.ctpで
?php
foreach ($country_list as $country_name) {
echo $country_name;
echo '<br/>';
}
?>
以下のエラーがでてしまい、全く上手くいきません。
Notice (8): Undefined index: Movie [APP/Controller/MoviesController.php, line 135]

同じプラグインを使用している方で、問題の解決方法をご存知のかたがいましたら教えてください!

回答の条件
  • 1人5回まで
  • 登録:
  • 終了:2012/03/18 13:41:42
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

回答1件)

id:Cherenkov No.1

回答回数1504ベストアンサー獲得回数493

$country_list = $this->Movie->Country->find

$country_list = $this->Movie->find
とか

他28件のコメントを見る
id:tdoi

よかったです。
ちなみに、上記のコードのforeach無駄ですよ。
以下で十分かと。

$this->Prg->commonProcess();
$country_cond = explode('|', $this->request->params["named"]["country_id"]);
$country_list = $this->Movie->Country->find('list', Array('conditions' => Array('Country.id' => $country_cond)));
$this->set('country_list', $country_list);
2012/03/15 01:41:42
id:kyouryukun

長い間、ありがとうございました。
たいへん参考になりました!!

2012/03/15 11:35:55
  • id:tdoi
    さらっとしか見てないですが、SearchPluginと関係のないところの問題な気がしますね。

    ちなみにですが、
    $this->Prg->commonProcess();
    $this->paginate['conditions'] = $this->Movie->parseCriteria($this->passedArgs);
    とかは今回の記述からは省略しているってことですよね?

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません