[SOLVED] Display related News articles excluding current article

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
homebrewruss
Forum Members
Forum Members
Posts: 12
Joined: Wed Mar 04, 2009 3:18 pm

[SOLVED] Display related News articles excluding current article

Post 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
Last edited by homebrewruss on Mon Sep 28, 2009 12:24 pm, edited 1 time in total.
homebrewruss
Forum Members
Forum Members
Posts: 12
Joined: Wed Mar 04, 2009 3:18 pm

Re: Display related News articles excluding current article

Post 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}
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

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

Post by nicmare »

AWESOME! thats is exactly what i was looking for! nice idea :-)
thank you very much
Post Reply

Return to “Modules/Add-Ons”