Sunday, 1 April 2012

Changing the Search Results Template in Joomla

If you add the standard Search Module in your Joomla! installation, you may find that the search results appear in the template layout of your Front or Home page and not the template layout of your 'interior' pages. In my website, I only have the left module position filled for certain pages, so I have a huge empty space:




Wouldn't it be great if you could just specify the template layout?! ...well you can, really easily...

I had a quick Google and found a few suggestions:

  • Add a hidden field <input type="hidden" name="Itemid" value="20" /> to the end of your [template-name]/html/mod_search/default.php file) 
  • Add the 'Set ItemID=20' value in the mod_search Module.

I didn't really know the significance of them and knew there'd be a better way. So here it is. You'll see where the 20 comes from in step 4.


1. Create a new Menu, called NOTUSEDsearch or something like that. I always put NOTUSED in to remind me what it's about.



2. Add a new Menu Item of type Search:



3. Add the Title:



4. Click Apply and you'll be given an ID for the search results page. Note this down. In my case it's 20.




5. Click Close or Save. Remember, this Menu is not going to be used so don't publish it! The only reason we needed it was to find the ID of the search results page.The search results page will use this ID that we've just generated. The Link (index.php?option=com_search&view=search) will actually load up in the default template though. Try typing it into the address bar of the browser and you'll see.

6. Go to the Template Manager and select the new template that you want to choose for the layout of your search results. Add the new menu item you created:






As you can see I've used the No column template for many other menu items including my Forum which takes the full screen width to render correctly.

7. Test!





8. Style! Remember to style everything Joomla! can throw at you!

5 comments:

  1. Thanks alot you save me hours, keep it up

    ReplyDelete
  2. I need a tutorial how to customize the whole template ie.
    Remove the new search box it gives you
    remove Search for options
    remove Ordering:
    remove Display #

    basically customize it for myself

    any help would be appreciated

    ReplyDelete
  3. I would like to appreciate the effort behind creating this article, thanks for sharing and updating it with us
    website security certificate | ssl certificate price | Dedicated Servers in India | cheap dedicated hosting india

    ReplyDelete