search
top

Blocks in Magento eCommerce

If you are using Magento Ecommerce, you might have created ‘Static Blocks’ for integrating custom functionality.

I am listing here the method to create CMS Blocks.

Suppose you want a custom box to be displayed on right column.

1) Go to admin section there is menu ‘Static Blocks’ in ‘CMS’.

2) Click ‘Add New Block’.

3) Fill in the fields
For example,
Block Title – Right Box
Identifier – right_box
Store View – Select ‘all Store Views’
Status – Enabled
And in ‘Content’ Box whatever html content you want,
For this example Put this data :

	<div class="box base-mini">
	    	<div class="head">
			<h4>Box</h4>
		</div>          
		<div class="content">
		     box content will go here
		</div>
	</div>

And Press ‘Save Block’.

4) For displaying the box in frontend ,open file app/design/frontend/your package/your theme/layout/page.xml

Replace the line

 <block type="core/text_list" name="right" as="right"/> 

with

 
<block type="core/text_list" name="right" as="right">            	 
<block type="cms/block" name="chatbox">
   <action method="setBlockId"><block_id>right_box</block_id></action>
</block>    			 
</block>
 

‘right_box’ is the block identifier.

5) A box will be displayed in right column

If you want to display the ‘Block’ content in other template page you cat get the content by

 
<?php
 echo $this->getLayout()->createBlock('cms/block')->setBlockId('right_box')->toHtml()  
//for getting the content of Admin block having ID:right_box 
?>

Leave a Reply

top