Jump to content

guzzlemett

New Members
  • Posts

    2
  • Joined

  • Last visited

guzzlemett's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Have been given the solution, the code is now simplified to the following: $RSS = array(); foreach($items as $item){ $feed = $item->get_feed(); $tmp=array(); if ($feed){ $tmp['date'] = $item->get_date('j M Y, g:i a'); $tmp['content'] = $item->get_content(); $tmp['title'] = $item->get_title(); $tmp['link'] = $item->get_link(); $tmp['description'] = $item->get_description(); $tmp['source'] = $item->get_item_tags('','source')[0]["data"]; array_push($RSS, $tmp); } } $smarty->assign( $params['assign'], $RSS ); And in the smarty template: <div class="cont"> <a href="{$entry.link}" target="_new">{$entry.title}</a> <br /> <span class="date">Published on: <strong>{$entry.date}</strong></span><br /> <span class="source">Via : <strong>{$entry.source}</strong></span><br /> </div>
  2. From an RSS feed, using SimplePie I'm trying to access the value of the additional element 'source' using 'get_item_tags', and then use this alongside the usual title, description and so on for each item to be displayed in a news page using a smarty template. Problem is that I can't access and convert 'news_source' into an item, instead of using the echo method as stated in the simplepie documentation. When adding as $tmp['news_source'] nothing is being returned. Code snippet follows: $RSS = array(); foreach($items as $item){ $feed = $item->get_feed(); $tmp=array(); $news_source = $item->get_item_tags('','source'); /* echo $news_source[0]["data"]; */ if ($feed){ $tmp['date'] = $item->get_date('j M Y, g:i a'); $tmp['content'] = $item->get_content(); $tmp['title'] = $item->get_title(); $tmp['link'] = $item->get_link(); $tmp['description'] = $item->get_description(); $tmp['news_source'] = $item->$get_news_source(); array_push($RSS, $tmp); } } $smarty->assign( $params['assign'], $RSS ); Then in the smarty template, the output: <div class="cont"> <a href="{$entry.link}" target="_new">{$entry.title}</a><br> <span class="date">Published on: <strong>{$entry.date}</strong></span> <span class="source">Via : <strong>{$entry.news_source}</strong></span><br /> </div> Thanks for any help or advice.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.