0

Ok, So I've made a module and use it to manage all the custom layouts on my store. Now I need to just add some blocks to certain pages using the template. I added the following line to my custom layout:

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

And inside the Update Layout XML I added the following:

<reference name="cms_left">
    <block type="cms/block" name="cms_left_test" before="-">
        <action method="setBlockId"><block_id>cms_left_test</block_id></action>
    </block>    
</reference>

And encase its relevent here is part the relevant part of my moudles config.xml that handles this custom layout:

<cms_pages module="page" translate="label">
    <label>cms pages</label>
    <template>page/cms_pages.phtml</template>
    <layout_handle>cms pages</layout_handle>
</cms_pages>

From what I know this should now display the cms_left_test block on this page, however it;s not working. Have I missed out a step somewhere? I tried looking up some examples, but because I'm drawing bits and pieces from all over I'm not sure if my approach is totally correct.

1

How is the block 'cms_left' defined in your layout? Or better yet ''IS IT defined?'. You are calling this:

<reference name="cms_left">
    <block type="cms/block" name="cms_left_test" before="-">
        <action method="setBlockId"><block_id>cms_left_test</block_id></action>
    </block>    
</reference>

But in order to be able to reference a block, the block should exist.

I think you are missing this piece of xml in your custom layout file.

<default>    
    <reference name="root">
        <block type="core/text_list" name="cms_left" as="cms_left" translate="label">
            <label>CMS left block</label>
        </block>
    </reference>
</default>
2

From what it looks like, the block cms_left is not defined anywhere. In order for it to work, you should define it as core/text_list somewhere in your layout definitions. Then you can reference it and add new blocks to it, like you are trying to do. Assuming cms_left is a direct child of root, you can do the following:

<reference name="root">
    <block name="cms_left" type="core/text_list" />
</reference>

Make sure you add this before your code above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.