We will use Zend_Feed_Rss library to parse the RSS feed, which came with Magento and
Zend Framework. Open your favorite PHP IDE and fire up the Magento project.
1. Create a new file named tweets.phtml in the app/design/frontend/YOUR_
PACKAGE/YOUR_THEME/template/callouts directory. In my case, it's app/
design/frontend/base/default/template/callouts.
2. Now paste the following code inside it and change the Twitter username and feed
URL with your desired one:
<?php
/**
* @var String $twitterUsername
* change $twitterUsername with your desired username
*/
$twitterUsername = 'packtpub';
/**
* @var String $twitterFeedUrl
* change it with your twitter feed. you will find it at the right
side of your twitter page
*/
$twitterFeedUrl = 'http://twitter.com/statuses/user_
timeline/17778401.rss';
$tweets = new Zend_Feed_Rss($twitterFeedUrl);
?>
<div class="box base-mini mini-compare-products">
<div class="head">
<h4>Tweet! Tweet!!</h4>
</div>
<?php foreach ($tweets as $key=>$tweet): ?>
<?php if($key <= 4): ?>
<div class="content"><p><?php echo str_
replace("$twitterUsername:", "", $tweet->title); ?></p></div>
<?php endif; ?>
<?php endforeach; ?>
</div>
3. Now log in to your Magento backend. Navigate to the page CMS | Pages | Home
page | Design | Layout Update XML.
4. Let's add the following content at the end and save these changes:
<reference name="right">
<block type="core/template" name="tweets" as="getTweets"
template="callouts/tweets.phtml" translate="label">
<label>Twitter updates</label>
</block>
</reference>
5. Guess what! We are done! Now check your Magento home page. Your home page..