I've been trying to work out how to filter news items included in search results by category and user login state.
I finally found a rather simple solution, so I thought I'd share it here.
Create a summary template in the news module, which only creates a smarty array with the chosen information. In my case this was the id's of news items for public access. So, something like this:
Code: Select all
{foreach from=$items item=entry}
{$publicnews[]=$entry->id}
{/foreach}
{news summarytemplate="show_in_search" category="public"}
and filter:
Code: Select all
{if ccUser::loggedin()}
<li> {$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a></li>
{else}
{if $entry->module == 'News' && $entry->modulerecord|in_array:$publicnews}
<li> {$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> </li>
{/if}
{/if}
Hope this helps.