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
  • email
  • TwitThis
  • it does work, but when you search again on the new page, the old template comes back to haunt you...
  • CDMoore
    I have an issue with a site.  It was working well for a while and now instead of the article showing as the home page...it shows the search result page though the search mod has been disabled.  Any help appreciated.
  • Jeff Porter
    Closest I've come to finding a solution to a similar problem. Is there a workaround for com_search, as opposed to mod_search?
  • Grace Tariaga
    Definitely helped me a lot! Thanks!!
  • Just what i was looking for, i must of deleted some menu items for it to occur in the first place, any way i changed the id to the article menu id. Thanks buddy
  • Oli Cameron
    Thank you!!!!
  • Dsdsdsd
    dsdsd
  • kamay
    Wow thank u for this
  • Hi John,

    Any idea why search results are not showing on my site (linked in name) and how i can fix it? Results are being returned by the search module (standard) and show on the log, but for some reason they are not displayed on the results page...
  • Hi Nick

    If I type in "test" I get a search results page with nothing found (but content never the less), however searching for "seo" (which I expect there are lots of content) returns a blank page.

    So I think the SERP templates haven't been created property or there is a bad line of code that's stopping the results displaying. Try following the steps in the post and recreated your SERP templates, if that works then you can start customising.
  • Hi John,

    I followed the steps outlined but no change,
    Send me an email via enclosed addy or the contact form page on my site if you fancy the job of fixing it for a reasonable cost, thanks for your help. Nick.
  • Cgranados
    Excelent! thanks for sharing this.
    Grettings from Costa Rica
  • Jool Manalili
    Or as an alternative, you can use an itemID used by any of the inside pages that use the global template. In that way you don't have to create a hidden menu.
  • Hank
    Great! except you don't need to cerate a new hidden menu..

    Just use the code and set the value to be 9999999
  • Joel Manalili
    This is brilliant.
  • @Rajesh have a look at this related post for an idea:
    http://www.johncrumpton.com/jo...
  • Rajesh
    Really helpful,
    How can I change my poll module result page in a different template. I changed the template of my poll through template manager but the result is showing in the default template.
    Help
  • Thanks a lot man
  • 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?</template>
  • 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