Page 1 of 1
Search a group of set pages
Posted: Thu May 27, 2021 12:47 pm
by Barrowboy
Hi
Is there anyway to set the search to a group of pages but not the whole site.
Can this be done without setting pages to not searchable.
Could there be two different search buttons?
Thanks.
Re: Search a group of set pages
Posted: Thu May 27, 2021 2:15 pm
by DIGI3
I don't think the search module has any functionality for that built-in. It would need to be forked and modified.
A poor man's workaround could perhaps be a custom result template that filters out any results from unwanted pages.
Re: Search a group of set pages
Posted: Thu May 27, 2021 3:56 pm
by velden
I think the 'poor man's solution' isn't that bad.
It will probably be way more flexible than anything the module itself could offer. Especially considering the details of the request.
Re: Search a group of set pages
Posted: Thu May 27, 2021 4:11 pm
by Barrowboy
Thanks
I will into it on the lines you suggested.
Not hopeful I know enough about it though, even though I am a poor man.
Re: Search a group of set pages
Posted: Thu May 27, 2021 6:27 pm
by velden
Consider thess examples:
Code: Select all
{if 1|in_array:[2,3,4]}yes{else}no{/if}
{if 2|in_array:[2,3,4]}yes{else}no{/if}
Makes sense?
Then check the sample result template of Search
Code: Select all
...
{foreach from=$results item=entry}
<li>{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
{*
You can also instantiate custom behaviour on a module by module basis by looking at
the $entry->module and $entry->modulerecord fields in $entry
ie: {if $entry->module == 'News'}{News action='detail' article_id=$entry->modulerecord detailpage='News'}
For content pages the module is 'content' and modulerecord the page id.
*}
{/foreach}
...
For content pages the module is 'content' and modulerecord the page id
Then find the page IDs of the pages you want to include. Let's assume page IDs 2,3 and 4
(untested)
Code: Select all
{if $entry->module == 'content' && $entry->modulerecord|in_array:[2,3,4]}{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>{/if}