odd_duck
odd_duck

Reputation: 4101

Magento - Remove blocks from footer on CMS page

In my magento store I have the recently viewed products block and newsletter signup block inside my footer as shown with the below code all working ok:

footer.phtml

<?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>

<?php echo $this->getChildHtml('footer.newsletter') ?>

On one of my CMS pages i want to hide these 2 blocks. In the design admin tab for my CMS page i have already hidden the breadcrumbs with the below in the Custom Layout Update XML section, again working fine:

<reference name="root">
    <remove name="breadcrumbs" />
</reference>

I cannot seem to come up with the correct code to remove these blocks. I have tried several lines of code for each block:

<reference name="footer">
    <remove name="reports.product.viewed" />
</reference>

<reference name="root">
    <remove name="footer.reports.product.viewed" />
</reference>

<reference name="footer">
    <action method="unsetChild"><alias>reports.product.viewed</alias></action>
</reference>

Upvotes: 2

Views: 3965

Answers (3)

Pilar Villamil
Pilar Villamil

Reputation: 1

System menu -> Configuration -> Advanced button under the Advanced section on the left. -> find Mage_Newsletter drop-down menu to Disable -> Click Save

From https://briansnelson.com/How_to_Disable_Magento_Newsletter_Module

Upvotes: 0

Oscprofessionals
Oscprofessionals

Reputation: 2174

Check if CMS page:

$page = Mage::getSingleton('cms/page');
if ($page->getId()) {

}
else{

<?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>

<?php echo $this->getChildHtml('footer.newsletter') ?>

}

OR

if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
  // CMS page
}
else{

// your code 

}

Upvotes: 0

Slimshadddyyy
Slimshadddyyy

Reputation: 4073

Try using below code in your layout XML file

<cms_page>
    <reference name="footer">
        <remove name="footer-product-viewed" />
        <remove name="your_footer_newsletter_block_name" />
    </reference>
</cms_page>

Code in your footer.phtml

<?php echo $this->getLayout()->createBlock('reports/product_viewed', 'footer-product-viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>

<?php echo $this->getChildHtml('footer.newsletter') ?>

If your footer newsletter block is still not removed try passing false parameter, which will not allowed the block to render from cache.

<?php echo $this->getChildHtml('footer.newsletter', false) ?>

Hope it helps.

Upvotes: 1

Related Questions