[SOLVED] Excluding Contant aliasis from search result

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
gmb
New Member
New Member
Posts: 5
Joined: Sun Dec 04, 2011 2:51 pm

[SOLVED] Excluding Contant aliasis from search result

Post by gmb »

Hi,

I'm using search module 1.7 and would like to exclude all contant aliases from search result.
Last edited by gmb on Sun Mar 11, 2012 2:20 pm, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Excluding Contant aliasis from search result

Post by Wishbone »

You can modify your search results template to exclude anything you want.
gmb
New Member
New Member
Posts: 5
Joined: Sun Dec 04, 2011 2:51 pm

Re: Excluding Contant aliasis from search result

Post by gmb »

Thanks for replying,

I've been trying to do just that. I used the default searchresult template with minor adjustment, but can't get it right.

Code: Select all

{debug}
<h3>{$searchresultsfor} "{$phrase}"</h3>

{if $itemcount > 0}
 
<pre> {$entry|print_r}</pre> 
<ul>

  {foreach from=$results item=entry}

{if !{$page_alias}} {* this is the part I've added*}

  <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'} 
  *}

{/if}

  {/foreach}
</ul>
<p>{$timetaken}: {$timetook}</p>
{else}
  <p><strong>{$noresultsfound}</strong></p>
{/if}
here are some other if statements I've also tried to use, but nothing seems to work. I don't know how to reach content alias type.

{if Content-type != content aliases}
{if $entry->module != 'ContentAliases'}
{if $entry->Content-type != 'ContentAliases'}
{if ($content_obj->mType != 'ContentAliases')}

Please tell me how, i'm stuck bigtime.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Excluding Contant aliasis from search result

Post by Wishbone »

Couple of issues:

{if !{$page_alias}} should have given you an error... Correct: {if !$page_alias}, but this isn't the problem.. $page_alias isn't set for each search result.. It will contain the value of the current page, and is always set.

Try: {if $entry->module} .. This is set only if the result is a module entry, like a news article, or calendar date item and is not set if it's a content page.
gmb
New Member
New Member
Posts: 5
Joined: Sun Dec 04, 2011 2:51 pm

Re: [SOLVED] Excluding Contant aliasis from search result

Post by gmb »

It works!

Thanks a lot!!!
Post Reply

Return to “CMSMS Core”