Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Getting “Please enter valid XML data” when trying to add unique left and right block to a category page
 
beejaye
Jr. Member
 
Total Posts:  11
Joined:  2011-02-25
 

Getting “Please enter valid XML data” when trying to add unique left and right block to a category page

I am trying to add a unique blocks to several category pages. So, for example:

* add a non-product category page about dogs in general, and have unique “dog” blocks
* add a non-product category page about cats in general, and have unique “cat” blocks

On the “dog” category page, under “Custom Design"/"Custom Layout Update” the following code works (where “left_dog_block” is a static block):

<reference name="left">
<block type="cms/block" name="left_dog_block" before="-">
<action method="setBlockId"><block_id>left_dog_block</block_id></action>
</block>
</reference>

AND, the following works (where “right_dog_block” is another static block)

<reference name="right">
<block type="cms/block" name="right_dog_block" before="-">
<action method="setBlockId"><block_id>right_dog_block</block_id></action>
</block>
</reference>

BUT - I am getting a “Please enter valid XML data” error when I combine the code:

<reference name="left">
<block type="cms/block" name="left_dog_block" before="-">
<action method="setBlockId"><block_id>left_dog_block</block_id></action>
</block>
</reference>
<reference name="right">
<block type="cms/block" name="right-dog-block" before="-">
<action method="setBlockId"><block_id>right_dog_block</block_id></action>
</block>
</reference>

Any suggestions?
Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
beejaye
Jr. Member
 
Total Posts:  11
Joined:  2011-02-25
 

I just tried adding the same code today - and it worked! Go figure - I swear I put the same code in, but perhaps there was an extra space or something?

The code that I put in the category page (under \"Custom Design\” tab in the Custom Layout Update field) is below. This is a slick way to add additional blocks that you want unique by page, as there are NO template updates needed - you stay in the admin area!

<reference name=\"left\">
<block type=\"cms/block\" name=\"left_dog_block\" before=\"-\">
<action method=\"setBlockId\"><block_id>left_dog_block</block_id></action>
</block>
</reference>
<reference name=\"right\">
<block type=\"cms/block\" name=\"right-dog-block\" before=\"-\">
<action method=\"setBlockId\"><block_id>right_dog_block</block_id></action>
</block>
</reference>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shizzler
Jr. Member
 
Total Posts:  9
Joined:  2011-03-02
 

I got exactly the same issue. I got two references I would like to add to a Category Custom Layout Update. When I add them separately it works ok. When I add both I get the “Please enter valid XML data.” error.

Reference 1
<reference name="head">
<action method="addItem">
<type>skin_js</type>
<script>js/my_script.js</script>
</action>
</reference>

Reference 2
<reference name="left">
<block type="core/template" name="submenu.men" template="submenus/men.phtml" />
</reference>

I already removed all spaces, but that doesn’t seem to be solution. The only solution I see is to call the js file from the men.phtml file.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shizzler
Jr. Member
 
Total Posts:  9
Joined:  2011-03-02
 

Encapsulating both references with <reference name="root"> did the trick for me:

<reference name="root">
<
reference name="head"
<
action method="addItem"
<
type>skin_js</type
<
script>js/my_script.js</script> 
</action
</
reference
<
reference name="left"
<
block type="core/template" name="submenu.men" template="submenus/men.phtml" /> 
</
reference>
</
reference>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Enteractiva
Sr. Member
 
Avatar
Total Posts:  80
Joined:  2010-05-13
Dominican Republic
 
Shizzler - 01 April 2011 04:00 AM

Encapsulating both references with <reference name="root"> did the trick for me:

<reference name="root">
<
reference name="head"
<
action method="addItem"
<
type>skin_js</type
<
script>js/my_script.js</script> 
</action
</
reference
<
reference name="left"
<
block type="core/template" name="submenu.men" template="submenus/men.phtml" /> 
</
reference>
</
reference>

Worked for me on version 1.5 smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top