babyewok Posted February 27, 2018 Share Posted February 27, 2018 (edited) OK, so usually I would use simple pie to show a wordpress feed on a website. I am trying to use the RSS block module but am having trouble with it. I need to show the featured image which I have added to the feed via a media tag. My feed looks like this: <title>Post title</title> <link>http://website.com/blog/2018/02/post/</link> <pubDate>Mon, 15 Feb 2018 08:39:00 +0000</pubDate> <dc:creator><![CDATA[Kitty & Dulcie]]></dc:creator> <category><![CDATA[Uncategorised]]></category> <category><![CDATA[sale]]></category> <guid isPermaLink="false"></guid> <description><![CDATA[Blah Blah blah […]]]></description> <media:content xmlns:media="http://search.yahoo.com/mrss/" medium="image" type="image/jpeg" url="http://website.com/blog/wp-content/uploads/2018/02/image.-2B-25C2-25A3285.00-2Bwww.website.com_.jpeg" width="123" height="185" /> </item> and I would usually then show the feed like this: <ul> <?php foreach ($feed->get_items($start,$length) as $item): ?> <li> <a href="<?php echo $item->get_permalink(); ?>" class="blog-img"><?php if ($enclosure = $item->get_enclosure()) { echo '<img alt="'.$item->get_title().'" src="' . $enclosure->get_link() . '" />'; } ?></a> <h3><a href="<?php echo $item->get_permalink(); ?>"><?php echo substr($item->get_title(), 0, 60); $str = $item->get_title(); if (strlen($str) > 60) echo '...'; ?></a></h3> <p><?php echo substr($item->get_description(), 0, strpos($item->get_description(), ' ', 210)). '…'; ?> <a href="<?php echo $item->get_permalink(); ?>" class="more-link">Continue Reading</a></p> <?php endforeach; ?> </li></ul> Can anyone enlighten me as to how I can achieve the same with the rss block module? Edited February 27, 2018 by babyewok (see edit history) Link to comment Share on other sites More sharing options...
babyewok Posted February 27, 2018 Author Share Posted February 27, 2018 (edited) Oh an also why can't I show a feed from the same domain? Prestashop is installed to the root domain and wordpress is installed to a separate directory. I can show feeds form the same domain with simplepie. Edited February 27, 2018 by babyewok (see edit history) Link to comment Share on other sites More sharing options...
babyewok Posted February 27, 2018 Author Share Posted February 27, 2018 OK, so I have tried all sorts. The latest is adding this to blockrss.php: if (isset($xmlValues['media:content']) ) { $xmlValues['imageurl'] = (string)$item->{'media:content'}->attributes()->url; } after $xmlValues = array(); foreach (self::$xmlFields as $xmlField) $xmlValues[$xmlField] = $item->__get($xmlField); $xmlValues['enclosure'] = $item->getEnclosure(); // First image if (isset($xmlValues['content']) && $xmlValues['content']) { preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/', $xmlValues['content'], $image); if (array_key_exists(1, $image) && $image[1]) { if ($image[1][0] == '/') $image[1] = 'http:'.$image[1]; // Try if distant image exist : timeout 0.3s $context = stream_context_create(array('http' => array('timeout' => 0.3))); if (file_get_contents($image[1], false, $context, -1, 1) !== false) $xmlValues['image'] = $image[1]; } } and then trying to grab the url in the template with... {$rss_link.imageurl} Doesn't work. I am sure I have got the logic wrong somewhere - please help! Link to comment Share on other sites More sharing options...
ukbaz Posted January 29, 2019 Share Posted January 29, 2019 Hi - I'm trying to do the same thing in Prestashop 1.7 with the ps_rssfeed block. Did you come up with a solution? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now