Page 1 of 1

[SOLVED] Display related News articles excluding current article

Posted: Thu Sep 24, 2009 5:12 pm
by homebrewruss
Hi all,
On the news detail page for each article I'm trying to display a news article in detail and then all other News articles in the same category in summary form beneath.

Here's an example:
http://tinyurl.com/yebcyg9

This works in a way but doesn't exclude the post currently being viewed in the list of articles below.

Can anyone help me achieve this - I guess i'll probably have to call something in my detail template.

Thanks
Russell

Re: Display related News articles excluding current article

Posted: Mon Sep 28, 2009 12:24 pm
by homebrewruss
..well that was easier than i initially thought - with a bit of help from print_r  and smarty :)

In the news summary template i was using to display related news articles i just grabbed the id of the news item i was displaying in detail and assigned it a new variable 'currentitem'.
Then after the foreach loop to display all items i just added an if statement to test the id of each entry in the $items array.

Code: Select all

{assign var='currentitem' value=$entry->id}

{foreach from=$items item=entry}
{if $entry->id !=$currentitem}

{* code to display each item in summary goes here *}

{/if}
{/foreach}

Re: [SOLVED] Display related News articles excluding current article

Posted: Sat May 01, 2010 9:45 am
by nicmare
AWESOME! thats is exactly what i was looking for! nice idea :-)
thank you very much