I'm building a prototype search application using CakePHP and I have a search controller that has the following code so far:
class SearchController extends AppController
{
var $name = 'Search';
var $uses = array();
function index ( $query )
{
$query = $_GET['q'];
$this->set('title_for_layout', $query. ' – smplr');
// if no query then redirect to home
if ( !$query )
{
$this->redirect(array('controller' => 'home', 'action' => 'index'));
}
}
}
So this would be fired when a user has something like this: domain.com/search?q=Hello
My question is how to use the query passed into index() ?
At the moment I have to manually create a new variable to grab the query string using $_GET which I'm sure is NOT the way to do this using Cake.
Any help much appreciated. Thanks