Hi
I've got a problem with the Search module and the way it works with the News module.. hoping someone can help.
If I perform a search with the search module, and click on a result that was found in a news article, the page it takes you to doesnt use the 'Detail' page I have set from within the News modules options... instead it loads the news article into the content area of the search results.
If I go to the Search extensions options there is a setting 'Page for individual module results' where if I select the News detail page it will work as expected... but then this will obviously cause problems with results from other modules!
I hope that all made sense! Is there a way to get the intended behaviour? Where news results will open in the News Detail page?
Help with News module and Search - displaying results in correct template
-
- Forum Members
- Posts: 200
- Joined: Mon Nov 26, 2018 3:09 pm
Re: Help with News module and Search - displaying results in correct template
I'm not sure I understand the problem but this is a snippet i kept from an old sample search result template (i never used it this way though):
Code: Select all
{if $entry->module == 'News'}{News action='detail' article_id=$entry->modulerecord detailpage='News'} {/if}
Re: Help with News module and Search - displaying results in correct template
I was looking for a workaround for this recently too, the Search module doesn't honour the News detailpage in the results. I ended up hardcoding the detailpage in the search results template like this:
Where '54' is the ID of the page I want the detail results displayed in.
Code: Select all
{if $entry->module == 'News'}
<li>{$entry->title} - <a href="{root_url}/news/{$entry->modulerecord}/54/{$entry->urltext}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
{else} etc.
Not getting the answer you need? CMSMS support options
Re: Help with News module and Search - displaying results in correct template
1 --- in the search results template :
2 --- in your search result page : in tab Logic add into Smarty data : define id of your news detail page
Then if you change your news detail page, you just have to modify id defined in your search result page, and it allow others admin to manage it without having access to search result template
Code: Select all
{if $entry->module == 'News'}
{* --- use this if NOT url_rewriting --- *}
{*
<li>{$entry->title} - <a href="{$entry->url|replace:"returnid=$page_id":"returnid=$news_page_id"}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
*}
{* --- use this if active url_rewriting --- *}
{assign var=article_id value=$entry->modulerecord}
<li>{$entry->title} - <a href="{$entry->url|replace:"$article_id/$page_id":"$article_id/$news_page_id"}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
{else}
<li>{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a> ({$entry->weight}%)</li>
{/if}
Code: Select all
{$news_page_id='9' scope=root}
Last edited by filto on Fri May 06, 2022 2:48 am, edited 3 times in total.
-
- Forum Members
- Posts: 200
- Joined: Mon Nov 26, 2018 3:09 pm
Re: Help with News module and Search - displaying results in correct template
Great - many thanks - I'll test these out!