[SOLVED] Search module: multiple search templates?

General project discussion. NOT for help questions.
Post Reply
jsmonzani
Forum Members
Forum Members
Posts: 54
Joined: Mon Apr 03, 2006 10:58 am

[SOLVED] Search module: multiple search templates?

Post by jsmonzani »

Hello

I am preparing a website into which I need to add two search boxes:
- search the full website
- search only in news

Is it possible to let the visitor search in the news module exclusively? (I'm not talking about filtering by tags but plain text search).

It could be tempting to modify the Search module template with something like:

Code: Select all

{if $entry->module == 'News'}...
Unfortunately, as opposed to other modules, there is only one template available in Search, and I would need two of them (full website- and news-only-search).

Is there any way to do that or should I develop my own module? I couldn't find anything in the forge and forums.

Thank you very much for your help!

Best regards,

Jean-Sébastien
Last edited by jsmonzani on Tue Feb 19, 2013 3:38 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Search module: multiple search templates? (search in New

Post by calguy1000 »

multiple templates are not strictly necessary, they are a convenience.

if talking about the search form template you can work around this in a number of ways, one of them is:

a: set a smarty variable before calling the search module
b: check for that smarty variable in the search module form template.
i.e:

Code: Select all

{assign var='search_newsonly' value=1}
{Search}
in your search form template:

Code: Select all

{if isset($search_newsonly)} ... {else} .... {/if}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
jsmonzani
Forum Members
Forum Members
Posts: 54
Joined: Mon Apr 03, 2006 10:58 am

Re: Search module: multiple search templates? (search in New

Post by jsmonzani »

calguy1000: Your efficiency is always a pleasure :)
Yes, I had thought of a smarty global variable too, or a POST variable hack. It seems that it's the kind of workaround I would need to go for.

Thanks for your help!
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: [SOLVED] Search module: multiple search templates?

Post by psy »

See http://forum.cmsmadesimple.org/viewtopi ... =4&t=61947 for an alternative method that works equally well.
jsmonzani
Forum Members
Forum Members
Posts: 54
Joined: Mon Apr 03, 2006 10:58 am

Re: [SOLVED] Search module: multiple search templates?

Post by jsmonzani »

Thank you very much Psy, it's indeed a good starting point for me.

Best regards,

JS
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: [SOLVED] Search module: multiple search templates?

Post by blackhawk »

Thank you calguy1000! That is a great information!
Post Reply

Return to “General Discussion”