简体   繁体   English

自定义joomla搜索结果页面布局

[英]Customizing joomla search result page layout

The joomla search results appear on the home page. joomla搜索结果显示在主页上。 I want it to show up on a new page. 我希望它显示在新页面上。 According to some online posts I had to modify the mod_search.php to set the item id to a non existing item so i set it to 0, but the problem is that the changes are not being reflected in my search module at all. 根据一些在线帖子,我不得不修改mod_search.php以将项目ID设置为不存在的项目,因此我将其设置为0,但是问题是这些更改根本没有反映在我的搜索模块中。 I also tried putting a hidden field called itemid in the modules/mod_search/tmpl/default/default.php form but even that is not picked, I set the form target equal to _blank and tried to change the action page of the form to say index.php?Itemid=0 instead of index.php but all of this does not seem to reflect on the search module. 我还尝试在模块/mod_search/tmpl/default/default.php表单中放置一个名为itemid的隐藏字段,但是即使未选中,我也将表单目标设置为_blank并尝试更改表单的操作页面以说index.php?Itemid = 0而不是index.php,但是所有这些似乎都没有反映在搜索模块上。 When i manually change the itemid in the browser location box to 0, the results show up on a different page (thats what i want). 当我手动将浏览器位置框中的itemid更改为0时,结果显示在另一个页面上(这就是我想要的)。

Please suggest what should I do? 请建议我该怎么办?

在Joomla 2.5中,mod_search属性中有“ itemId”字段,如果将其设置为不存在的项目,则它将清除绑定到某些菜单项(页面)的模块中的搜索结果页面,而仅保留绑定到“全部”的模块”页面。

Try to change request method of search form: 尝试更改搜索表单的请求方法:

<form ... method="get">
<input type="hidden" name="itemId" value="0" />

or like this 或像这样

<form action="...?itemId=0" method="post">

I know this is an older post, but I have found an easy solution for this for use with Joomla 1.6 and wanted to share it. 我知道这是一篇较旧的文章,但是我找到了一个与Joomla 1.6一起使用的简单解决方案,并希望与他人分享。 It is a core hack, which isn't optimal because it will go away during upgrades, but it is easy to do. 这是一个核心hack,并不是最佳选择,因为它会在升级过程中消失,但是很容易做到。

What folks (like me) have been searching for is to allow a user to enter text in the search box on a page and have the results display in a blank page within the template, rather than have the results display within the same page along with other content, or be forced to use a menu item to send users to a separate search page. 像我这样的人们一直在寻找的是允许用户在页面上的搜索框中输入文本,并将结果显示在模板内的空白页面中,而不是将结果与其他内容,或被迫使用菜单项将用户发送到单独的搜索页面。

When using a Search box within the Joomla! 在Joomla中使用搜索框时! page to initiate a search, it is the 'component' portion -- not the 'module' -- of Search that is being used. 页面以启动搜索,正在使用的是搜索的“组件”部分而不是“模块”。 There is a section in the Search Component Controller that either sets an ID for use with a menu, or automatically sets the result to come from and display in the requesting page. 搜索组件控制器中有一个部分,可以设置用于菜单的ID,或者自动设置结果来自请求页面并在请求页面中显示。 We just need to turn that off to send the search results to a blank page. 我们只需要将其关闭即可将搜索结果发送到空白页。

So, in /components/com_search/controller.php -- comment out the following code: 因此,在/components/com_search/controller.php中,注释掉以下代码:

/*              // set Itemid id for links from menu
    $app    = JFactory::getApplication();
    $menu   = $app->getMenu();
    $items  = $menu->getItems('link', 'index.php?option=com_search&view=search');

    if(isset($items[0])) {
        $post['Itemid'] = $items[0]->id;
    } else if (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
        $post['Itemid'] = JRequest::getInt('Itemid');
    }
*/

This will display the search results within the content portion of a blank page of your template. 这将在模板的空白页的内容部分内显示搜索结果。 At least it did for me. 至少对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM