0

Hi i'm using below code in my cms page->design->layout update xml

<reference name="left">
<block type="cms/block" name="Cms Pages Left Sidebar" as="Cms Pages Left Sidebar" before="-">  
       <action method="setBlockId"><block_id>cms_pages_left_sidebar</block_id></action>  
    </block>
</reference>

Everything working fine, but i have more then 200 pages, so it's a tidious process to update in all pages.

So i've added the same in mytheme's config.xml but now the issue is it's coming in product and category pages too.

Is there any way to show them only in cms pages ?

6

Welcome to Magento.SE and great job getting this far in figuring out layout XML.

Firstly, I would advise you that you do not place this in the config.xml file. It is advisable to place it into a layout update file.

Secondly, you're very close here - the only thing you need to do is target the CMS "handle" (a fancy name for the topmost node in the layout xml) - looks like you're already targeting something - likely default or root.

Instead use this:

<cms_page>
    <reference name="left">
    <block type="cms/block" name="Cms Pages Left Sidebar" as="Cms Pages Left Sidebar" before="-">  
           <action method="setBlockId"><block_id>cms_pages_left_sidebar</block_id></action>  
        </block>
    </reference>
</cms_page>
5
  • 1
    Simply going to add that the important bit, the <cms_index_index> node, can be quickly determined by checking the class assigned to the <body> tag on the page you want to change.
    – pspahn
    Jul 22 '14 at 5:29
  • @philwinkle Thanks for your quick response. I'm new to magento so i'm wondering which is layout update file ? You mean to say I have to add it in theme's layout's folder's layout.xml ? if so i've done it but it's not reflecting. Any idea where i'm doing wrong ? Jul 22 '14 at 5:35
  • Try first adding it to the theme's layout/local.xml file - if that does not suffice try including it in another existing layout xml file for testing purposes. Make sure to disable caches while debugging.
    – philwinkle
    Jul 22 '14 at 5:37
  • 1
    I've used <cms_page> instead of <cms_index_index> and it worked. Jul 22 '14 at 5:54
  • Great, even better. I'll update the question
    – philwinkle
    Jul 22 '14 at 5:54

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.