Thanks for the response. As advised, I solved this by adding a else
statement to it. now its working well. Another thing, would you please
advice me a quick solution from which i can hide model name from my
URL created out of search string.

currently my url looks like:
http://my.website.com/medical/results/Medicine.search:cancer/Medicine.author_id:5

I wanted it to be like this:
http://my.website.com/medical/results/search:cancer/author_id:5

Thanks again and
Thanks in advance.

Regards.



On Mar 10, 6:16 pm, rethab <[email protected]> wrote:
> What is the exact error message you're facing?
>
> Maybe something like: 'Use of undefined variable'? Some of your
> variables are only set if the if - statements execute. However, you're
> using them later on. Make sure you either initialise them with default
> values or don't use them below.
>
> On 10 Mrz., 12:32, "Mr.Jayesh" <[email protected]> wrote:
>
>
>
>
>
>
>
> > I am in process of creating a search function for my site. It has
> > three search parameters. I have worked it this way.
> > The search functions properly with pagination. The problem is small; I
> > am not able to identify how to setoptionalfield. When a user passes
> > all the parameters for search there is no error message; but if one of
> > those is left blank; I get an error stating "Undefined variable:
> > medicine".
>
> > My controller search function code is as under.
>
> > if (!empty($this->passedArgs)) {
>
> >         if(isset($this->passedArgs['Article.search'])) {
> >         $keyword = $this->passedArgs['Article.search'];
> >                 $this->data['Article']['search'] = $keyword;
> >                 $this->set('keyword');
> >     }
>
> >         if(isset($this->passedArgs['Article.author_id'])) {
> >         $author = $this->passedArgs['Article.author_id'];
> >                 $this->data['Article']['author_id'] = $author;
> >                 $this->set('author');
> >     }
>
> >         if(isset($this->passedArgs['Article.area'])) {
> >         $medicine = $this->passedArgs['Article.medicine'];
> >                 $this->data['Article']['medicine'] = $medicine;
> >                 $this->set('area');
> >     }
>
> >         $conditions = array(
> >                                 "Article.author_id LIKE" => "%$author%",
> >                                 "Article.medicine LIKE" => "%$medicine%",
>
> >                                 "or" => array(
>
> >                                         "Article.medication LIKE" => 
> > "%$keyword%",
> >                                         "Article.description LIKE" => 
> > "%$keyword%"
> >                         ))
> >                 ;
> >         } else {
> >                 
> > $this->redirect(array('controller'=>'Articles','action'=>'search'));
> >     }
> >         $articles = $this->paginate('Article', $conditions);
>
> >         $authors        = $this->Article->Author->find('list', 
> > array('fields' =>
> > array('author_name'),
> >                         'conditions' => array('Author.status_id' => 1)));
> >         $this->set(compact('authors', 'articles'));
>
> >         $this->layout = 'resultlist';
> >         $this->set('title_for_layout', 'Search Result');
>
> >         }
>
> > I think, I am not able to set upoptionalfield properly. So, please
> > help us with your valuable suggestion.
> > Thanks in advance.
>
> > Regards.

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to