0

Adding block B inside block A as child block is not working for me. Block A is a static block in cms page.

A category page display mode is : Static block only > displays block A The static block has {{block type="core/template" name="contactForm" template="contacts/form.phtml"}}.

I am trying to call a child block inside this contactForm, which is not working.

xml layout:

<cms_page>
    <reference name="contactForm">
        <block type="core/template" name="customblock" template="amodule/customblock.phtml"/>
    </reference>
</cms_page>

template: contacts/form.phtml has this code inside

<?php echo $this->getChild('customblock')?>
1
<your_layout_handle>
    <reference name="root">
        <block type="core/template" name="block1" template="path/to/template.phtml">
            <block type="core/template" name="block2" template="path/to/template.phtml" />
        </block>
    </reference>
</your_layout_handle>

Now to call the:

block1 =

<?php echo $this->getBlockHtml('block1'); ?>

block2 =

<?php echo $this->getChildHtml('block2'); ?>
  • #Prince, you are completely wrong. Why would I create two new blocks which doesn't even do anything in contactForm block ? – rbncha Nov 6 '17 at 9:08
0

For the work workaround I have initialized the block in the contact form itself like this which works:

<?php echo $this->getLayout()->createBlock('amodule/customblock', 'customblock', array('template' => 'amodule/customblock.phtml'))->toHtml();?>

might be helpful for you too

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.