CMS Blocks in Magento

Call CMS Block from phtml:
If you want to call a cms block in your phtml file then simple add the following code.


Call phtml in CMS Block and CMS Page:
If you want to call a phtml file from CMS Page or CMS Block then paste the following code in content area.

{{block type="core/template" template="templateFolder/file_name.phtml"}}

Call phtml from phtml:
You can also call a phtml file from your any phtml file.


Get CMS Page Identifier:
You can identify your cms page by the following code. This is a unique identifier in every store.


Get CMS Page Url:
You can find the cms page url by this code.


Display Category products in CMS page:
If you want to load products in your cms page of a particular category then simply use the following code (here category_id is your category id of your store)

{{block type="catalog/product_list" category_id="2" template="catalog/product/list.phtml"}}

Add Layered navigation in CMS Page:
If you want add a Layered Navigation in your CMS Page where you showing products then add the following xml code in cms page design tab -> update xml.

	

Get Current Category:
Now you find the current category name by the following code by Mage::registry.


Hope this helps!!

You may also like

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *