CakePHP Doing search in home page -


i wondering how search on home page property.

i trying understand concept , have viewed multiple website still can't understand how done.

all need push in right direction. need cases in relation example x model , search on it. while mine search performed home property.

any appreciated.

the code have placed in controller not sure correct. home controller

public function index() {         //populate localities dropdownlist           app::import('model','locality');         $locality = new locality('locality');         $this->set('localities',$locality->find('list', array('fields' => array('id', 'fullname'))));          app::import('model','condition');         $condition = new condition('condition');         $this->set('conditions',$condition->find('list', array('fields' => array('id', 'condition'))));          app::import('model','category');         $category = new category('category');         $this->set('categories',$category->find('list', array('fields' => array('id', 'category'))));          app::import('model','servicetype');         $servicetype = new servicetype('servicetype');         $this->set('servicetypes',$servicetype->find('list', array('fields' => array('id', 'service_type'))));     } 

the view

<?php      echo $this->form->create('property',array('contoller' =>'home', 'action'=> 'search'));     echo $this->form->input('pricefrom',array('style'=> 'width:100%;'));     echo $this->form->input('priceto',array('style'=> 'width:100%;'));     echo $this->form->input('locality_id',array('style'=> 'width:100%;'));     echo $this->form->input('condition_id',array('style'=> 'width:100%;'));     echo $this->form->input('category_id',array('style'=> 'width:100%;'));     echo $this->form->input('service_type_id',array('style'=> 'width:100%;'));     echo $this->form->end('search');     ?> 

you can create element handles search functionality, targeting form function inside controller.

say, if want search properties, can inside propertycontroller:

public function search() {     //your search functionality, $this->property->find('all');, or adding conditions } 

then can add element has search form, naming, say, search.ctp (inside view/elements folder):

$this->form->create('property', array('type' => 'get')); $this->form->input('search'); $this->form->end('search'); 

and in home page, can add element with:

echo $this->element('search'); 

the thing elements can reuse in other views, or in layout


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -