Magento - Add skin CSS and Javascript (JS) to head through layout XML

Posted by Damodar Bashyal on November 12, 2012

 

Today I downloaded one free magento banner slider extension/module. First thing I noticed was it was adding css and js on the template (.phtml) directly like this.

<script type="text/javascript" src="<?php echo $this->getJsUrl('bannerslider/banner1.js') ?>"></script>

<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/bannerslider/banner1.css');?>" media="all" />

It should be ok to add js inside the body, but it's recommended to add css on the head section.

More»

Magento - Meta Description Tag on Product View Page

Posted by Damodar Bashyal on October 27, 2012

 

After installing facebook all in one extension, QA team was testing facebook send button. Then they found that send button had some funny description. When i checked page source, i found that meta description was using product description which had html formats. If meta description is filled in there will be no such issue but if left empty, it takes description from product.

As core Magento doesn't strip html tags for meta description, let's override it to suit our need:

First create file:

app\code\community\Technooze\Tcatalog\Block\Product\View.php

More»

Magento Enterprise Tabs - How to select specific tab?

Posted by Damodar Bashyal on October 06, 2012

 

This is how tab config looks in - catalog.xml

<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
	<action method="addToParentGroup"><group>detailed_info</group></action>
	<action method="setTitle" translate="value"><value>Product Details</value></action>
</block>
<block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">
	<action method="addToParentGroup"><group>detailed_info</group></action>
	<action method="addToParentGroup"><group>detailed_info</group></action>
	<action method="setTitle" translate="value"><value>Additional Information</value></action>
</block>
<block type="cms/block" name="payment_options_tab" as="payment_options_tab" template="catalog/product/view/custom_tab_content.phtml">
	<action method="setBlockId"><block_id>payment_options_tab</block_id></action> 
	<action method="addToParentGroup"><group>detailed_info</group></action> 
	<action method="setTitle" translate="value"><value>Payment Options</value></action> 
</block> 
<block type="cms/block" name="shipping_calculator_tab" as="shipping_calculator_tab" template="catalog/product/view/custom_tab_content.phtml"> 
	<action method="setBlockId"><block_id>shipping_calculator_tab</block_id></action> 
	<action method="addToParentGroup"><group>detailed_info</group></action> 
	<action method="setTitle" translate="value"><value>Shipping Calculator</value></action> 
</block>

content of - custom_tab_content.phtml

More»