I have a module layout file 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 the template file at top of the content area at the frontend.
I want to show this file content just after the header block ends.
So how can I move this block to the after header?
I have tried this as well in 2columns-left.phtml, but didn't work
<?php echo $this->getChildHtml('ampromo_notification'); ?> 
Currently, the layout files and template files exist in the base>default folder, while I am using the theme folder. So can it be a problem?
4 Answers 4
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" />
- 
 above code didn't work.Shashank Kumrawat– Shashank Kumrawat2017年05月16日 13:12:41 +00:00Commented May 16, 2017 at 13:12
<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– Shashank Kumrawat2017年05月16日 13:12:17 +00:00Commented May 16, 2017 at 13:12
- 
 Are you sure ? did you clean a cache ?2017年05月16日 13:20:50 +00:00Commented May 16, 2017 at 13:20
- 
 Yes.. content is showing at the top of the page now.Shashank Kumrawat– Shashank Kumrawat2017年05月16日 13:22:18 +00:00Commented May 16, 2017 at 13:22
- 
 did you removed<?php echo $this->getChildHtml('ampromo_notification'); ?>in phtml ?2017年05月16日 13:28:34 +00:00Commented May 16, 2017 at 13:28
- 
 yes, ofcourse..I didShashank Kumrawat– Shashank Kumrawat2017年05月16日 14:28:23 +00:00Commented May 16, 2017 at 14:28
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>
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.