0

I'm using the CMS to display the product list block on my homepage via this markup in the CMS editor

{{block type="catalog/product_list" mode="grid" name="home.catalog.product.list" template="catalog/product/list.phtml" column="one_column" size="small"}}

I wanted to add additional blocks beneath it, however the blocks from that markup don't end up in the layout? Using Alan Storm's Layoutviewer module to inspect the layout the block I'm looking for (with name home.catalog.product.list) doesn't show in the output.

Considering that Alan's module is somehow missing elements added by the CMS, I went ahead and tried to add the blocks I'm after via Custom Layout Update XML under Design in the CMS editor for the homepage:

<reference name="home.catalog.product.list">
    <block type="page/html_pager" name="product_list_toolbar_pager"/>
</reference>

The pager markup isn't added to the page though, probably because the home.catalog.product.list block isn't in the layout... But how is that possible, the markup for the catalog/product_list block is on the homepage, it's just not present in the layout (that I can tell).

My question - why isn't the block I'm adding from the CMS showing up in the layout?

1

The problem is, that you cannot define a block name when dynamically adding a block via the block directive.

The Filter class to generate a Block from the block directive in cms content is declared here: https://github.com/bragento/magento-core/blob/1.9/app/code/core/Mage/Cms/Model/Template/Filter.php

It is extended from the Mage_Core_Model_Email_Template_Filter.

If you look at the blockDirective method, it just passes null as the name for the block: https://github.com/bragento/magento-core/blob/1.9/app/code/core/Mage/Core/Model/Email/Template/Filter.php#L179

This results in a anonymous block beeing created (I think it gets a random name somewhere): https://github.com/bragento/magento-core/blob/1.9/app/code/core/Mage/Core/Model/Layout.php#L443

  • Thanks for this. I have a hacky way of adding the block in a template that's working right now, but I'd prefer to figure out how to do it using a layout update. – quickshiftin Mar 20 '16 at 19:14
0

Have you tried use the attribute "name_in_layout"?

{{block type="catalog/product_list" mode="grid" name="home.catalog.product.list" name_in_layout="home.catalog.product.list" template="catalog/product/list.phtml" column="one_column" size="small"}}

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.