• 1 reply
  • Latest Post - ‏2007-05-02T12:10:58Z by SystemAdmin
17 Posts

Pinned topic php help

‏2007-04-24T19:39:52Z |
I am using magpierss in conjunction with smarty to display xml feeds on my site.

I have used the following php code:

/* The folder where this file is located. Change to whatever you need */
$mydir = "/rssdemo";

/* Include magpierss and Smarty library */

/* Create a template object for further use */
$tpl = new Smarty();

/* Set folders for Smarty object. This folders have to exist on your web server (Check A.3) */
$tpl->template_dir = $_SERVER.$mydir.'/templates/';
$tpl->compile_dir = $_SERVER.$mydir.'/templates_c/';
$tpl->config_dir = $_SERVER.$mydir.'/configs/';
$tpl->cache_dir = $_SERVER.$mydir.'/cache/';

/* The URL of the feed we want to include */
$url = "";

/* magpierss does all the work! */
$rss = fetch_rss($url);

/* Uncomment the following line to see the object and array data returned. Good to see which other information has been processed by magpierss */
// echo "<pre>"; print_r($rss); echo "</pre>";

/* If the RSS could be parsed, add it to the template */
if ($rss) {
/* Sends the feed title to the template engine */
/* Sends the RSS items as an array */
else {
/* RSS problem? */
$tpl->assign("feedtitle","Problem with: $url");

/* Fill the template file itemlist.html with the information and return it */
$feedhtml = $tpl->fetch($_SERVER.$mydir."/templates/itemlist.html");
/* Do with $feedhtml whatever you want */
echo $feedhtml;

What do I need to add to control the number of items the displayed and how do I make them appear in a new random order each time the page is refreshed?
Updated on 2007-05-02T12:10:58Z at 2007-05-02T12:10:58Z by SystemAdmin
  • SystemAdmin
    17 Posts

    Re: php help

    I'm not all that familiar with how Smarty works, but I'm actually in the middle of starting a Smarty project right now, so I'll get back to you shortly.

    Unless somebody else has the answer...?

    • Nick