Search a group of set pages

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
Barrowboy
Forum Members
Forum Members
Posts: 223
Joined: Mon Dec 16, 2013 4:09 pm

Search a group of set pages

Post 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.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Search a group of set pages

Post 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.
Not getting the answer you need? CMSMS support options
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Search a group of set pages

Post 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.
Barrowboy
Forum Members
Forum Members
Posts: 223
Joined: Mon Dec 16, 2013 4:09 pm

Re: Search a group of set pages

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Search a group of set pages

Post 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}
Post Reply

Return to “CMSMS Core”