Reputation: 531
I'm making a search for joomla, after clicking search button I am getting this url:
index.php?searchword=aa&task=search
How can I create a view or task for it?
Upvotes: 2
Views: 1063
Reputation: 151
If you use the basic joomla search component you will find the views in
/components/com_search/views/search/tmpl
If you edit the view then its advisable to use template overrides, to ensure you will not lose your views on upgrade : http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
addition :
If you are building a component and you want a task to execute like that, then use this in your YourComponentName.php
.
$controller = JController::getInstance('FrontendSuite');
$controller->execute(JRequest::getVar('task'));
$controller->redirect();
And add the task as a function in your controller.php
. You will get something like this :
function search(){
$searchword = JRequest::getVar('searchword');
//Do your magic
}
As Valentin pointed out just below, you will need to add option=com_yoursearchcomponent
to your URL for Joomla to call your component.
Adding Views to your component is explained quite well in the link Valentin posted below, http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_a_view_to_the_site_part
Hope this helps,
Good luck
Upvotes: 2
Reputation: 42622
Your URL will be like:
index.php?option=com_yoursearchcomponent&task=search&keyword=xxx
So you need to create a component. Have a look at the Developing a Model-View-Controller Component.
Then you will have in your controller or subcontroller the task search which will call the view search, where you will have the appropiate template for the view.
Upvotes: 1