4

I have a module layout file like below

<default>
    <block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" before="-" />
    <reference name="content">
        <action ifconfig="ampromo/messages/display_notification" method="append"><block>ampromo_notification</block></action>
    </reference>
</default>

This file shows the content of template file at top of content area at frontend.

I want to show this file content just after header block ends.

So how can I move this block to after header?

I have tried this as well in 2columns-left.phtml, but didn't work

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

Currently, layout file and template files exist in base>default folder, while I am using theme folder. So can it be a problem ?

0

Replace

<block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" before="-" />

with this

<block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" after="header" />
0
<reference name="header">
    <reference name="top.container">
        <block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" after="-" />
    </reference>
</reference>

Remove <?php echo $this->getChildHtml('ampromo_notification'); ?>

  • using above code, it shows content in header block at the top of page, but I want to show it just after the header ends and just before the content starts. – Shashank Kumrawat May 16 '17 at 13:12
  • Are you sure ? did you clean a cache ? – PЯINCƏ May 16 '17 at 13:20
  • Yes.. content is showing at the top of the page now. – Shashank Kumrawat May 16 '17 at 13:22
  • did you removed <?php echo $this->getChildHtml('ampromo_notification'); ?> in phtml ? – PЯINCƏ May 16 '17 at 13:28
  • yes, ofcourse..I did – Shashank Kumrawat May 16 '17 at 14:28
0

This is for after header, inside content, before all other blocks.

<reference name="content">
    <reference name="top.container">
        <block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" before="-" />
    </reference>
</reference>

Or within global_messages (before content)

<reference name="global_messages">
    <reference name="top.container">
        <block name="ampromo_notification" type="ampromo/notification" template="amasty/ampromo/notification.phtml" before="-" />
    </reference>
</reference>
0

As a last resort you can do stuff like this in template html

echo $this->getLayout()
          ->createBlock('Chapagain\HelloWorld\Block\HelloWorld')
          ->setTemplate('Chapagain_HelloWorld::helloworld.phtml')
          ->toHtml();

And remove the other XML reference. Whilst I appreciate this isn't the best approach we all have deadlines.

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.