Page 1 of 1

[SOLVED] Excluding Contant aliasis from search result

Posted: Fri Mar 09, 2012 3:12 pm
by gmb
Hi,

I'm using search module 1.7 and would like to exclude all contant aliases from search result.

Re: Excluding Contant aliasis from search result

Posted: Sat Mar 10, 2012 5:59 pm
by Wishbone
You can modify your search results template to exclude anything you want.

Re: Excluding Contant aliasis from search result

Posted: Sat Mar 10, 2012 6:52 pm
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.

Re: Excluding Contant aliasis from search result

Posted: Sat Mar 10, 2012 10:57 pm
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.

Re: [SOLVED] Excluding Contant aliasis from search result

Posted: Sun Mar 11, 2012 5:04 pm
by gmb
It works!

Thanks a lot!!!