





















































Customize the appearance of your Magento 1.4 e-commerce store with Magento's powerful theming engine
Facebook (http://www.facebook.com) is a social networking website that allows people to add each other as 'friends' and to send messages and share content.
Move the mouse over the image to enlarge it.
As with Twitter, there are two options you have for integrating Facebook with your Magento store:
The Facebook 'Like' button allows Facebook users to show that they approve of a particular web page and you can put this to use on your Magento store.
To get the markup required for your store's 'Like' button, go to the Facebook Developers website at: http://developers.facebook.com/docs/reference/ plugins/like. Fill in the form below the description text with relevant values, leaving the URL to like field as URLTOLIKE for now, and setting the Width to 200:
Click on the Get Code button at the bottom of the form and then copy the code that is presented in the iframe field:
The generated markup should look like the following:
<iframe src="http://www.facebook.com/plugins/like.php?href=
URLTOLIKE&layout=standard&show_faces=true&width=
200&action=like&colorscheme=light&height=80"
scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:200px; height:80px;"
allowTransparency="true">
</iframe>
You now need to replace the URLTOLIKE in the previous markup to the URL of the current page in your Magento store. The PHP required to do this in Magento looks like the following:
<?php
$currentUrl = $this->helper(‘core/url’)->getCurrentUrl();
?>
The new Like button markup for your Magento store should now look like the following:
<iframe src="http://www.facebook.com/plugins/like.php?href=
".<?php $currentUrl = $this->helper(‘core/url’)->getCurrentUrl();
?>".
&layout=standard&show_faces=true&width=200&action=
like&colorscheme=light&height=80»
scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:200px; height:80px;"
allowTransparency="true">
</iframe>
Open your theme's view.phtml file in the /app/design/frontend/default/m2/ template/catalog/product directory and locate the lines that read:
<div class="std"><?php echo $_helper->productAttribute($_product,
nl2br($_product->getShortDescription()), 'short_description') ?>
</div></div>
Insert the code generated by Facebook here, so that it now reads the following:
<div class="std"><?php echo $_helper->productAttribute($_product,
nl2br($_product->getShortDescription()), 'short_description') ?>
</div>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php
echo $this->helper('core/url')->getCurrentUrl();?>&layout=
standard&show_faces=true&width=200&action=like&
colorscheme=light&height=80" scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:200px; height:80px;"
allowTransparency="true">
</iframe>
</div>
Save and upload this file back to your Magento installation and then visit a product page within your store to see the button appear below the brief description of the product:
That's it, your product pages can now be liked on Facebook!