php - CakePHP 2.5 Basic Search different controller -
i writing website application in cakephp, have requirement have search box on homepage (pages/home.ctp, pagescontroller) searches content events page (events/index.ctp, eventscontroller).
i want search in fields of events table have 1 input box.
when user clicks search or hits enter should taken events/index.ctp page events listed.
- is possible? if pointers?
- if not how can achieve similar?
thanks steve
your actual search should done in model, since that's layer use retrieve data. if you're searching events, you'll put search()
method in event model.
then, in controller, can access search()
method. controller in depends on number of things can take account.
if you're in events controller:
$this->event->search($postdata);
if you're in different (but associated) controller:
$this->user->event->search($postdata);
if you're in different (non-associated) controller:
$this->loadmodel('event'); $this->event->search($postdata);
based on description, sounds you'd want make form post events controller's index()
method, can check if there search query submitted, , if there was, run search.
Comments
Post a Comment