1

I am trying to show newsletter block in the footer, except for the Homepage where I want to show it only in content area.

I used local.xml to move newsletter from left to footer:

<reference name="left">
   <remove name="left.newsletter"/><!-- Moved newsletter to the footer -->
</reference>

Then:

<reference name="footer">
    <!-- Move newsletter to the footer -->
    <block type="newsletter/subscribe" name="newsletter" as="newsletter" template="newsletter/subscribe.phtml"/>
</reference>

Easy, we have it in the footer. My problem is when showing it in homepage content. I used:

<cms_index_index>
    <reference name="content">
        <block type="newsletter/subscribe" name="my.newsletter" as="my.newsletter" template="newsletter/subscribe.phtml" before="-">
            <action method="setElementClass">
                <value>someclass</value>
            </action>
        </block>
    </reference>      
</cms_index_index>

This shows fine the block in content area. However to remove newsletter in the homepage footer I used within CMS page, design, layout update:

<reference name="footer">
    <remove name="newsletter"/>
</reference>

And also tried adding it in local.xml under cms_index_index

But it either shows twice in homepage (content and footer) or only in content, and not showing in any other page (in footer).

Is it related with caching? Am I using it wrong?

2

2 Answers 2

2

You could do this without calling remove and then having to recreate each block. Simply use the unsetChild and insert actions, they will allow you to move blocks around. The following xml should give you your desired results.

<default>
    <reference name="left">
        <action method="unsetChild">
            <name>left.newsletter</name>
        </action>
    </reference>
    <reference name="footer">
        <action method="insert">
            <block>left.newsletter</block>
        </action>
    </reference>
</default>
<cms_index_index>
    <reference name="footer">
        <action method="unsetChild">
            <name>left.newsletter</name>
        </action>
    </reference>
    <reference name="content">
        <action method="insert">
            <block>left.newsletter</block>
        </action>
    </reference>
</cms_index_index>
1

The footer has always been finicky for me when it comes to cache.

Try refreshing your Blocks HTML Output cache in Admin => System => Cache Management, and the Layouts cache probably wouldn't hurt.

If that doesn't fix it, see if there's an xml overriding it (if you are using a package/theme). If you're in linux, try:

cd app/design/frontend && grep -rl 'my.newsletter' .

That should yield files with that block declaration.

More about theme hierarchy can be found here: http://www.magentocommerce.com/design_guide/articles/working-with-magento-themes

Your Answer

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

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