1

I have created the Custom footer page and it is showing fine with 5 columns. Here I want to show the Newsletter Subscriber box in my custom .phtml file for this I tried to get <?php echo $block->getChildHtml('newsletter'); ?> and <?php echo $block->getChildHtml('form.subscriber'); ?> But nothing to display here. For this I have written below code.

layout/default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="footer-container">
            <referenceBlock name="footer_links" remove="true"/>
            <referenceBlock name="report.bugs" remove="true"/>
            <referenceBlock name="form.subscribe" remove="true"/>
            <!--<referenceBlock name="footer.newsletter" remove="true"/>-->
            <block class="Magento\Theme\Block\Html\Footer" name="custom_block" as="custom_block" template="Test_CustomFooter::custom.phtml"/>
        </referenceContainer>
    </body>
</page>

templates/custom.phtml

<?php /** @var  \Magento\Theme\Block\Html\Footer $block */ ?>
......code.....
<div class="col">
                <h3 class="title">EMail</h3>
                <div class="widget-content">
                    <?php echo $block->getChildHtml('newsletter'); ?>
                </div>
            </div>
.......code......

So could you please suggest me how to display here..

enter image description here

1

Change your layout xml code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="footer-container">
            <referenceBlock name="footer_links" remove="true"/>
            <referenceBlock name="report.bugs" remove="true"/>
            <referenceBlock name="form.subscribe" remove="true"/>
            <!--<referenceBlock name="footer.newsletter" remove="true"/>-->
            <block class="Magento\Theme\Block\Html\Footer" name="custom_block" as="custom_block" template="Test_CustomFooter::custom.phtml"/>
        </referenceContainer>
    </body>
</page>

To:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="footer-container">
            <referenceBlock name="footer_links" remove="true"/>
            <referenceBlock name="report.bugs" remove="true"/>            
            <block class="Magento\Theme\Block\Html\Footer" name="custom_block" as="custom_block" template="Test_CustomFooter::custom.phtml"/>
        </referenceContainer>
    </body>
</page>

Add below code in phtml file:

<?php echo $block->getChildHtml('form.subscribe'); ?>

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.