Hi I have a simplexml feed from a WP Blog working, but can't seem to get the image passed with the link.
I've pasted what I have in both *.php
and *.tpl
files below. I've tried quite a few ways, but can't seem to get it to show the image as the image source remains empty in html Can anyone help with code that works?
I have this in the PHP code:
public function hookDisplayFooter($params)
{
// Conf
$title = strval(Configuration::get('RSS_FEED_TITLE'));
$url = strval(Configuration::get('RSS_FEED_URL'));
$nb = (int) (Configuration::get('RSS_FEED_NBR')) ? (int) (Configuration::get('RSS_FEED_NBR')) : 5;
$cacheId = $this->getCacheId($this->name . '|' . date("YmdH"));
if (!$this->isCached($this->templateFile, $cacheId)) {
$rss_links = array();
if ($url && ($contents = Tools::file_get_contents($url))) {
try {
$xml = new SimpleXMLElement($contents);
$loop = 0;
if (!empty($xml->channel->item)) {
foreach ($xml->channel->item as $item) {
if (++$loop > $nb) {
break;
}
$rss_links[] = (array)$item;
}
}
} catch (Exception $e) {
Tools::dieOrLog($this->trans('Error: invalid RSS feed in "%module_name%" module: %message%', array('%module_name%' => $this->name, '%message%' => $e->getMessage()), 'Modules.Rssfeed.Admin'));
}
}
$this->smarty->assign(array(
'title' => ($title ? $title : $this->trans('RSS feed', array(), 'Modules.Rssfeed.Admin')),
'rss_links' => $rss_links
));
}
return $this->fetch($this->templateFile, $cacheId);
}
And this in the Smarty tpl file:
<div>
{if $rss_links}
<ul>
{foreach from=$rss_links item='rss_link'}
<div><img src="{$rss_link['image']}" width="50px" height="50px" ></div>
<li><div><a href="{$rss_link['link']}" title="{$rss_link['title']}" target="_blank">{$rss_link['title']} </a></li>
<a href="{$rss_link['link']}" class="more-blog">Continue Reading ></a></li><p> </p>
{/foreach}
</ul></div>
{else}
<p>{l s='No RSS feed added' d='Shop.Theme.Catalog'}</p>
{/if}