Page 1 of 1

[SOLVED] Search module: multiple search templates?

Posted: Tue Feb 19, 2013 3:27 pm
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

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

Posted: Tue Feb 19, 2013 3:31 pm
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}

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

Posted: Tue Feb 19, 2013 3:36 pm
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!

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

Posted: Fri Feb 22, 2013 11:00 pm
by psy
See http://forum.cmsmadesimple.org/viewtopi ... =4&t=61947 for an alternative method that works equally well.

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

Posted: Sat Feb 23, 2013 8:00 am
by jsmonzani
Thank you very much Psy, it's indeed a good starting point for me.

Best regards,

JS

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

Posted: Tue Feb 26, 2013 7:05 pm
by blackhawk
Thank you calguy1000! That is a great information!