2
There's several steps you need to follow to begin using Smarty templates within XOOPS. A quick
word of warning. I did not install and/or try this code so there may be a bug, so use this at your
own risk - but the general idea is right...
First, change your code to something like this:
le="color: #000000"><?php include '../../mainfile.php'; $xoopsOption['template_main'] = 'yahoo_feeds.html'; include XOOPS_ROOT_PATH . '/header.php'; require_once('class/simplepie/autoloader.php'); // We'll process this feed with all of the default options. $feed = new SimplePie(); // Set which feed to process. $feed->set_feed_url('http://news.yahoo.com/rss'); // Set the maximum number of items $items_per_feed = 15; // Run SimplePie. $feed->init(); // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it). $feed->handle_content_type(); $c=0; $feeditems = array(); foreach ($feed->get_items() as $item) { $feed = $item->get_feed(); if($c < $items_per_feed) { $feeditems[] = array('permalink' => $item->get_permalink(), 'title' => $item->get_title(), 'date' => $item->get_date(), 'desc' => $item->get_description() ); } else { // break out of feed loop if reached maximum number of feeds break; } $c++; } $xoopsTpl->assign('feed', $feeditems); include_once XOOPS_ROOT_PATH . '/footer.php';
Then in /
{modulename}/xoops_version.php you need to add:
le="color: #000000"><?php // Templates $modversion['templates'][] = array('file' => 'yahoo_feeds.html', 'description' => "Display Yahoo Feeds Template");
And finally you need to create the template file (./
{modulename}/templates/yahoo_feeds.html)
le="color: #000000"><?php <{foreach item=feed from=$feeds}> <hr /> <a href="<{$feed.permalink}>" target="_blank"><{$feed.title}></a><br /> <b><{$feed.date}></b><br /> <p><{$feed.desc}></p> <{/foreach}>
Then copy this to your module directory and make sure you update the module using the Admin control panel.