John Crumpton

If you use several templates on your Joomla site, such as a homepage template and a global template, you’ll know that the search results page irritatingly uses the homepage template and not your global template.

It is possible to change this by adding a hidden field to the search module, here’s how:

Within your homepage template folder create a new directory called “html” and then “mod_search”

Copy the “default.php” file from /modules/mod_search/tmpl/ into your newly created “mod_search” folder under your template folder.

Open this file at near the bottom just before the end of the form add:

<input type="hidden" name="Itemid" value="2" />

The value refers to the menu item, we need to create a new hidden menu in the administrator, add a search menu item, make a note of the menu’s Item ID, then add this to the above code under the value.

Don’t publish the hidden menu in the module manager, we’ve just creating this to get the Item ID of the search page.

Share:
  • Digg
  • del.icio.us
  • Facebook
  • LinkedIn
  • E-mail this story to a friend!
  • TwitThis
  • vkareh
    This help me a lot thanks..
    Just one question..
    I have a Banner and a menu that i would like to have on the search results page.. how can i do that..
    I did a menu item special for the results of the search and selected to show a banner but is not showing the banner..
  • Excellent work-around! Thanks!
  • Hi jurgenschulz - I'm going to rewrite the post to make it clearer. Create a new menu called "Not used" and add a "search" menu item. Make a note of the menu's itemID and add this as your hidden Itemid value.
  • jurgenschulz
    Hi John,

    I understand the overall idea what I need to change in order to get this to work, however Im stuck... My scenario:

    One Joomla site, 3 different templates. The overall site-template is called MG, then I have 2 parts of the site with their own template, HG and RG.

    For each of the three templates I have defined components and menues. Everything works fine.

    Furhermore I have defined a com_search module for each template.

    I have added the <input type="hidden"> to my /<template>/html/com_search/default.php and verified that it is passed in the HTTP POST - in order words the ID I put in get posted.

    However, still every search I do winds up displaying in the MG template (which is the default).

    I have read the paragraph where you state "The value refers to the menu item, so if you change this to “1″ it..." many times, but still do not understand what you want me to count?

    I have 29 different menu's defined (in order to support all three templates).... Can you be a bit more specific with the part about figuring out which ItemId to put in?
  • Dhruv Gami
    Awesome! This is great info! Thanks for putting this tutorial :)
  • Hi John, I'm currently redeveloping our existing site into Joomla, but as the search results display into the home page it also replicates a module which I have in the home page too... I've tried adding your code ( and folders) in to try to hide the module, but it's not working, the module still appears at the base of the search results.
    Any clues?
  • Hi Gavin - could you send across a url so I could see?
  • Alex
    Hi John,
    I found this bug and could not find how to resolve when finally I found your site.
    Thank you very much.
  • Hi Alex, you're very welcome and glad I could help!
  • Robert
    Hi,

    Thanks for this great tip. It works for me when I start the search from my homepage. But if I start from a 'content' page, the results revert to my homepage template. Have you any idea how to ensure that search results always go through to content page template?

    Thanks a million!
    Robert.
  • @Robert - you may have forgotten to copy the html overrides into your content template folder, it needs to go there in addition to the homepage template to work. Hope that helps!
  • jared
    Awesome. that did it. thanks a ton! saved a lot of time
  • You'll need to edit those php files to make it display as you wish. It will take time though!
  • Ah! Thanks so much John. You've helped me at least located it.
    I have to ask, how do I just "remove" the resulted tables? and simply and automatically display the results?
    Am I missing the picture. So close!!
    Thanks again,
    John
  • great trick!
    I would like to know how to have search results display exactly like the articles on the front page?
    Is there an easy way or in-depth mod'ing?
    John
  • You'd have to use template overrides to achieve this. So in your template folder make three new folders: "html/com_search/search". Now copy the contents of "/components/com_search/views/search/tmpl/" into this folder and then make changes to these php files. Hope that helps!
  • Carlos L
    Thanks, you make my day !!!
blog comments powered by Disqus