You would like to have a eCommerce power of Magento, but also have a blog to empower your business? In this case, you probably know that Magento doesn’t have some article manager in the box. Many clients seek for supplementary solution like WordPress to accomplish this goal. Ok, so you created a blog on same or different domain and you would like those articles to appear somewhere in Magento (probably sidebar). This article will explain how to do it.
Let’s create a file called latest_news.phtml in app/design/frontend/default/[your_theme]/template/callouts/latest_news.phtml
Now we will create a PHP block that will display the list of articles from RSS feed. We will use Inchoo RSS for demonstration purposes. In your scenario, replace it with your own valid RSS URL.
< ?php $channel = new Zend_Feed_Rss('http://feeds.feedburner.com/Inchoo'); ?> <div class="block block-latest-news"> <div class="block-title"> <h2>< ?php echo $this->__('Latest News') ?></h2> </div> <div class="block-content"> <ol id="graybox-latest-news"> < ?php foreach ($channel as $item): ?> <li><a href="<?php echo $item->link; ?>">< ?php echo $item->title; ?></a></li> < ?php endforeach; ?> </ol> </div> </div>
Now, we should decide where to place it. I assume you already know how Magento blocks and references work. Let’s assume you would like to place it in right column by default for whole catalog. In this case open your app/design/frontend/default/[your_theme]/layout/catalog.xml file and under “default” tag update “right” reference with something similar.
<reference name="right"> <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/> <block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml"/> <block type="core/template" name="right.latest.news" template="callouts/latest_news.phtml"/> </reference>
That’s it. You should be able to see the list of articles from RSS feed with the URLs. Hope this will help someone.