Take JSON out of the equation and simply check to see if the model- >find() call is returning anything echo debug($this->paginate());
Although from your post above it seems the problem is that you passing partners (plural) to the view and echoing partner (singlular) in the view. Why are you linking what happens with index and view to what happens in search? They should all be different actions with different views? HTH, Paul @phpMagpie P.S. I can highly reccomend CakeDC's search plugin On Sep 15, 2:51 pm, steveo <stevefis...@gmail.com> wrote: > Hey folks! I'm fairly new to CakePHP, but so far I love it! I had some > troubles getting a search interface to work against my database, but > after googling around I was finally able to put the pieces together > and get it to work. I am not in the process of enabling REST > interfaces and outputting in JSON/XML. I have everything working just > fine in my index and view templates (where I can just add .json > or .xml to the end of the URL and get the correct output. However, I > am not able to get JSON/XML output from a search! It looks like my > array is empty and I'm not sure how to pass the data over. > > I have the following code in my main controller: > > function search() { > if(empty($this->data)) { > $this->render(); > } else { > > $search_term=$this->data['Partner']['q']; > $conditions = array("partner_name LIKE" => "% > {$search_term}%"); > $partners=$this->Partner->find('all', > array('conditions' => $conditions)); > //var_dump($partners); > $this->Partner->recursive = -1; > $this->set('partners', $this->paginate()); > $this->set('partners', $partners); > $this->render("index"); > } > } > > Like I said, it works perfectly fine for the index and view, but not > for search. Instead, I get the following error: > > Undefined variable: partner [APP/views/layouts/json/default.ctp, line > 1]null > > Now, the tricky part. The json/default.ctp works for index and view, > so if I change the variable to "partners", it will no longer work for > index and view (in addition, changing to "partners" will not work for > the json/xml output either). Since I am seeing "null" in the error > message, I'm assuming that the partners variable is not getting passed > to the search (or default) template. Anyone think they can help me? > Thanks!!! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php