开发者

Customizing joomla search result page layout

开发者 https://www.devze.com 2022-12-21 15:32 出处:网络
The joomla search results appear on the home page. 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

The joomla search results appear on the home page. 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. 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. 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).

Please suggest what should I do?


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">


In Joomla 2.5 there is "itemId" field in mod_search properties, if set it to some non existent item than it clean ups search results page from modules which binding to some exact menu items(pages) and left only modules which are binding to "All" pages.


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. It is a core hack, which isn't optimal because it will go away during upgrades, but it is easy to do.

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! 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. 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:

/*              // 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消