0

I would like to show some of the colorful banner images for customers login/sign in pages. So, I have to create cms static block section to upload the banners and the same will be shown in front end. I tried to use content.top or columns.top for calling cms static block but it's not show anything in the front end.

<referenceContainer name="content.top">
    <container name="login.banner" htmlTag="div" htmlClass="banner-view">
        <block class="Magento\Cms\Block\Block" name="login-info">
            <arguments>
                <argument name="block_id" xsi:type="string">login-banner</argument>
            </arguments>
        </block>
    </container>
</referenceContainer>

Any help much appreciation.

Edit I would like to show this banner as like how category page banners are works. The banner should be shown before the page title section.

0

Use this php file:

<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('login-banner')->toHtml();?>

For Xml block_id == your block id

 <referenceContainer name="content.top">
<container name="login.banner" htmlTag="div" htmlClass="banner-view">
    <block class="Magento\Cms\Block\Block" name="login-banner">
        <arguments>
            <argument name="block_id" xsi:type="string">login-banner</argument>
        </arguments>
    </block>
</container>

  • I agree with you. But I would like to handle this one through layout XML instead of directly calling. – Maniprakash Chinnasamy Aug 11 '17 at 11:25
0

This is my work around which is worked as expected. Moved page main title to columns.top section and called CMS Static block section inside of columns.top section.

<move element="page.main.title" destination="page-title" after="banner.view.container"/>

<referenceContainer name="columns.top" after="-">
    <container name="banner.view.container" htmlTag="div" htmlClass="cms-banner-view" after="-">
        <block class="Magento\Framework\View\Element\Template" name="banner-view" template="Magento_Theme::cms-banner.phtml">
            <block class="Magento\Cms\Block\Block" name="cms-banner-section">
                <arguments>
                    <argument name="block_id" xsi:type="string">login-banner</argument>
                </arguments>
            </block>
        </block>
    </container>

    <container name="page-title" htmlTag="div" htmlClass="page-title" after="-">
        <referenceBlock name="page.main.title" after="columns.top">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">Log In / Sign Up</argument>
            </action>
        </referenceBlock>
    </container>
</referenceContainer>

Finally, Create phtml file to call the declared block name.

<?php echo $block->getChildHtml('cms-banner-section'); ?>

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.