We've been shortlisted for the Northern Digital Awards

Calling static blocks from anywhere in Magento

Magento eCommerce gives us the power to add our own snippets of html wherever we wish. Magento calls these snippets ‘static blocks’. To create a new block go to CMS > Static Blocks at the top right of this list click ‘Add New Block’.

Enter your title and unique identifier e.g. ‘top-advert’. Set the block to enabled and enter the content of the block into the WYSIWYG editor. This is all you need to do Magento side. To call the block onto the frontend of the website open up your template file. For example if I want to call my advert into my product listing I would open:

[pyg language=”bash”]

I want my advert to appear above the product list so I find the opening html for the products list and put this before it:

[pyg language=”php”]
getLayout()->createBlock(‘cms/block’)->setBlockId(‘top-advert’)->toHtml() ?>

Thats it, everything you need to know 🙂

Subscribe via email

Sign up to get notifications of new posts by email.

Share this article

Posted in Magento


Other posts you might like

Last Saturday 12th November myself and eight of my teammates donned our iWeb hoodies, packed our rain macs and headed…

Since our company was founded in 1995, we have been building fully bespoke eCommerce websites for our clients. We now…

MLUK16 definitely did not disappoint again this year, it brought a whole host of brilliant talks and exhibitors along with…

Call us on 01785 279920

Our friendly Magento experts are happy to answer your questions.

Contact us now

Email alerts

Get the latest eCommerce news, reviews and expert advice in your inbox.