4

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?

Viral Patel
1,1001 gold badge8 silver badges17 bronze badges
asked May 16, 2017 at 12:21
0

4 Answers 4

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" />
answered May 16, 2017 at 12:31
1
  • above code didn't work. Commented May 16, 2017 at 13:12
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'); ?>

answered May 16, 2017 at 12:31
6
  • 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. Commented May 16, 2017 at 13:12
  • Are you sure ? did you clean a cache ? Commented May 16, 2017 at 13:20
  • Yes.. content is showing at the top of the page now. Commented May 16, 2017 at 13:22
  • did you removed <?php echo $this->getChildHtml('ampromo_notification'); ?> in phtml ? Commented May 16, 2017 at 13:28
  • yes, ofcourse..I did Commented May 16, 2017 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>
answered May 17, 2017 at 12:39
0
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.

answered May 17, 2019 at 18:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.