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.

  1. is possible? if pointers?
  2. 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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -