Home > Magento Tips > Echo Custom Z Blocks

Echo Custom Z Blocks

Posted on: 12th Aug 2010 By: Adam Moss 1 Comment

Aheadworks have developed a great extension called Z Blocks, trouble is parts of the manual can be a bit ropey. It tells you how to set up the XML and configure the admin, but it doesn’t tell you how to call your XML into the your phtml file. For those of you without much Magento experience, knowing how to do this could be quite tricky so here’s the unofficial how-to:

1. Create your Z Block in the admin, I’m going to give mine the position name of ‘footerblock’.

2. Now, as I want my Z block to go in footer.phtml, open app > design > frontend > base > yourtheme > layout > page.xml and inside the footer block (<block type=”page/html_footer” name=”footer” as=”footer” template=”page/html/footer.phtml”>) add in your XML code:

<block type="zblocks/block" name="footer_block">
<action method="setPosition">
<position>footerblock</position>
</action>

3. Finally you just need to call it on the footer.phtml page with this code which you’ll have seen many times before:

<?php echo $this->getChildHtml('footer_block') ?>

If you want to call it in your head, or right or left column,  just relocate the XML and php call out and you’ll be laughing. This technique also works for calling out static blocks in areas of the phtml pages that you wouldn’t otherwise be able to edit. Just use this code to create the static block:

<block type="cms/block" name="new-block">   <action method="setBlockId"><block_id>new-block</block_id></action></block>

<?php echo $this->getChildHtml('new-block') ?>

It’s almost like an instant CMS! Keep reading the Magento Blog at Ecommerce Web Design for more hints and tips.

One Response to “ Echo Custom Z Blocks ”

  1. Chris
    #1 | 27th August 2010

    That helped me out a lot.

    Thank you.

Post A Comment

Your comments:
Enclose code snippets within the appropriate tags: [php][/php]   [js][/js]   [xml][/xml]   [css][/css]   [html][/html]
E.g: [php]<?php echo "hello world"; ?>[/php]

Search Blog

Archives

For the record...

Views & opinions in this blog are those of the individual and do not necessarily reflect those of E-commerce Web Design or the Creare Group.