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?

Marius
199k55 gold badges431 silver badges837 bronze badges
asked Apr 14, 2014 at 23:23
2
  • As a side note, make sure you know the difference between removing and unsetting blocks. Commented Apr 15, 2014 at 12:53
  • If your problem was solved, please select one of the answers as "accepted" to mark this question as solved. magento.stackexchange.com/help/accepted-answer Commented Sep 10, 2014 at 19:47

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>
answered May 27, 2014 at 13:43
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

answered Apr 15, 2014 at 1:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.