More and more retailers are using blogs and RSS feeds to help expand their businesses online presence. However Magento, the world’s leading open source eCommerce package doesn’t offer out of the box blog management, so many Magento shop owners are turning to other open-source software like WordPress to help meet their blogging demands. This leaves one thing uncovered, how to display these latest blog posts on a Magento shop homepage to help keep things fresh for SEO.
In this tutorial I will show you how to add an RSS feed to your Magento shop.
To start with, you will need to create a phtml file called rss_feed.phtml in the following directory:app/design/frontend/default/your-theme/template/callouts
In this file you will need to add the following code to call up the RSS feed:
PHP Code:
<?php $channel = new Zend_Feed_Rss(‘http://www.yourfeed.com/news/feed’); ?>
<?php $i = 0; ?>
<?php foreach ($channel as $item): ?>
<?php if ($i<3){ ?>
<?php echo $item->get_date(‘j F Y’); ?>
<p><?php echo $item->title; ?>
<a href="<?php echo $item->link; ?>">Read post »</a></p>
<?php } else { } ?>
<?php $i++; ?>
<?php endforeach; ?>
You will then need to change the URL to the URL of feed that you have set up in Feedburner.
Once you have done that you will need to open up the page.xml file inapp/design/frontend/default/your-theme/layout/ and then find the block where you would like to add the news feed to.
Add the following code to the page.xml file:
HTML Code:
<block type="core/template" name="latest.news" as="getNews" template="callouts/rss_feed.phtml"/>
Save this file and upload it with the rss_feed.phtml file.
Now you are ready to call the RSS in the main phtml pages and add the following code to the template files where you want the RSS to display:
PHP Code:
<?php echo $this->getChildHtml(‘getNews’) ?>
Save, upload and then style it up to fit in with your site’s design.
View more threads in the same category:
Bookmarks