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?

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" />
1
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'); ?>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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