我正在搜索joomla,点击搜索按钮后我得到了这个网址:
index.php?searchword=aa&task=search
如何为其创建视图或任务?
答案 0 :(得分:2)
如果您使用基本的joomla搜索组件,您将在
中找到视图 /components/com_search/views/search/tmpl
如果您修改视图,则建议您使用模板覆盖,以确保您不会丢失升级视图:http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
另外:
如果您正在构建一个组件,并且希望任务像这样执行,那么请在YourComponentName.php
中使用它。
$controller = JController::getInstance('FrontendSuite');
$controller->execute(JRequest::getVar('task'));
$controller->redirect();
并在controller.php
中将任务添加为功能。你会得到这样的东西:
function search(){
$searchword = JRequest::getVar('searchword');
//Do your magic
}
正如Valentin在下面指出的那样,您需要在网址中添加option=com_yoursearchcomponent
以便Joomla调用您的组件。
在下面发布的Valentin http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_a_view_to_the_site_part
链接中,可以很好地解释为您的组件添加视图希望这有帮助,
祝你好运答案 1 :(得分:1)
您的网址将如下:
?的index.php选项= com_yoursearchcomponent&安培;任务=搜索和安培;关键字= XXX
所以你需要创建一个组件。请查看 Developing a Model-View-Controller Component.
然后,您将在控制器或子控制器中进行任务搜索,该搜索将调用视图搜索,您将在该视图中获得视图的适当模板。