Avatar

News RSS in sidebar (Design/Themes)

by Alex ⌂, Tuesday, September 09, 2008, 10:05 (5701 days ago) @ Angelos

You explained how to show the latest topics on my website. Actually I want to do it the other way round. I want to add rss feeds of my website news stories on the sidebar of the forum. ;-)

OK, I see! Well, generally the code has to be separated into a program part and a display part. The program part (e.g. in includes/index.inc.php) would be something like this:

// include Magpie RSS:
require('path/to/magpierss/rss_fetch.inc'); 
// set charset:
define("MAGPIE_OUTPUT_ENCODING", "UTF-8"); 
// read the RSS Feed:
$rss = fetch_rss('URL_OF_THE_RSS_FEED'); 
// pass the data to Smarty:
$smarty->assign("rss_items",$rss->items);

The template code (e.g. in templates/defult/subtemplates/index.tpl.inc) should then read this way:

<ul>
{foreach from=$rss_items item=rss_item}
<li><a href="{$rss_item.link}">{$rss_item.title}</a></li>
{/foreach}
</ul>

Alex

locked
6097 views

Complete thread:

 RSS Feed of thread