1

I'm having a bit of trouble understanding how to update a custom block that I include in a CMS page using XML.

I inset the block using the standard shortcode in the CMS page, which works fine:

{{block type="catalog/product_list" category_id="16" 
template="catalog/product/slider_list.phtml"}}

I am trying to set the column count of this custom custom block; I've found that I need something like the following piece of XML:

<block type="catalog/product_list" name="catalog.product.slider_list"
template="catalog/product/slider_list.phtml">
    <action method="setColumnCount"><columns>4</columns></action>
</block>

I'm not exactly sure under which <reference /> block I should place the code... I looked in catalog.xml, and if I try to place it between <reference name="root" />, I do not get the correct behavior.

Thank you.

P.S. I found a solution thanks to this thread. I'd still like to know how to update the block by using XML. The solution I've mentioned is by using the shortcode:

{{block type="catalog/product_list" block_id="my_block" category_id="16"
template="catalog/product/slider_list.phtml" column_count="4"}}

1 Answer 1

2

Try <reference name="content">.

<reference name="root"> is the entire page which is typically made up of the following:

<reference name="head"> between the <head> html tags, used for adding js, css, meta

<reference name="header"> top of the page, in the <body> tags.

<reference name="content"> all blocks added directly under content gets rendered in main body

<reference name="left"> / <reference name="right"> all blocks added directly under left/right gets rendered in sidebar

<reference name="footer"> bottom of the page, in the <body> tags.

Here's a really comprehensive breakdown of blocks and layouts that i put together during my Magento certification studies...

Blocks

Describe the programmatic structure of blocks

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-1/

Describe the relationship between templates and blocks

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-2/

Describe the stages in the lifecycle of a block

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-3/

Describe events fired in blocks

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-4/

Identify different types of blocks

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-5/

Describe block instantiation

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-6/

Explain different mechanisms for disabling block output

http://www.danielnavarroymas.com/magento-certification-rendering-blocks-part-7/

Describe how a typical block is rendered

(Covered in above article: part 7)

Design layout, XML schema, and CMS content directives

Describe the elements of Magento's layout XML schema, including the major layout directives

http://www.danielnavarroymas.com/magento-certification-describe-directives-of-magento-layout-xml/

Register layout XML files

http://www.danielnavarroymas.com/magento-certification-register-layout-xml-files/

Create and add code to pages

http://www.danielnavarroymas.com/magento-certification-create-and-add-code-to-pages/

Explain how variables can be passed to block instances via layout XML

http://www.danielnavarroymas.com/magento-certification-explain-how-variables-can-be-passed-to-block-instances-via-layout-xml/

Describe various ways to add and customize javascript to specific request scopes

http://www.danielnavarroymas.com/magento-certification-describe-various-ways-to-add-and-customize-javascript-to-specific-request-scopes/

1
  • Thanks for the thorough explanation! Is it possible to add a block in a CMS page using the {{}} shortcode, and then customize it on a layout file? Commented Sep 9, 2013 at 7:47

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.