Answer the question
In order to leave comments, you need to log in
Why can't I get the search request in the module controller inside the public function index()?
It is necessary to add ajax search to the site and push the search by category into it.
I found a suitable search module - link
And everything seems to be clear, but I can't get the search query inside the public function index()
Below it is passed, for example, like this:
public function searchresults(){
if(isset($this->request->get)){
$keyword=$this->request->get['keyword'];
}else{
$keyword='';
}
public function getAutocomplite(){
if(isset($this->request->get)){
$keyword=$this->request->get['keyword'];
}else{
$keyword='';
}
$result=$this->model_extension_module_d_ajax_search->autocomplite($keyword);
$this->response->setOutput(json_encode($result));
}
Answer the question
In order to leave comments, you need to log in
There is a suspicion that you are doing something wrong, or do not quite understand how the functions in the controller are called. public function searchresults
and public function getAutocomplite()
work because they are accessed at these addresses:
index.php?route=extension/module/d_ajax_search/getAutocomplite&keyword=keyword
index.php?route=extension/module/d_ajax_search/searchresults&keyword=keyword
Accordingly, there is a keyword parameter in the request, which you can get via $this->request->get['keyword']
If you have an empty $this->request->get['keyword'] when accessing the index, then you don't have a get parameter either.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question