3

I'm trying to add New Products to the CMS home page. In order to get pagination to work, I must add the toolbar and pager blocks as children of the product list block.

 <reference name="content">
 <block type="mywebsite_catalog/product_new" name="home_products" template="catalog/product/home.phtml">
 <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
 <block type="page/html_pager" name="product_list_toolbar_pager"/>
 <action method="disableViewSwitcher"/>
 <action method="disableExpanded"/>
 </block>
 </block>
 </reference>

This is what I'm adding in the 'Design' tab of my CMS page, and it works, but the products are rendered after the CMS content - I need it between some of the CMS content.

As far as I know adding an 'inline' block using {{block type="..." template="..."}} is the only way to achieve that without editing the page's template. The problem for me with this is that it's not possible to nest inline blocks.

I've tried to programmatically add the child blocks, but was unsuccessful because it appears that inline blocks aren't actually part of any layout.

What's the best way of doing this?

asked Jul 31, 2014 at 13:35

2 Answers 2

1

Have you tried using {{layout handle=""}}?

Change your XML to the following:

<your_custom_handle>
 <block type="mywebsite_catalog/product_new" name="home_products" template="catalog/product/home.phtml">
 <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
 <block type="page/html_pager" name="product_list_toolbar_pager"/>
 <action method="disableViewSwitcher"/>
 <action method="disableExpanded"/>
 </block>
 </block>
</your_custom_handle>

Then use {{layout handle="your_custom_handle"}} in your CMS page or block.

answered Dec 21, 2014 at 13:16
1
  • Clever use of layout handles. Commented Dec 23, 2014 at 5:06
0

You could treat the CMS page as a "container" for the content's layout:

<reference name="content">
 <block type="cms/block" name="cms_content_before">
 <action method="setBlockId">
 <id>some_block_id</id>
 </action>
 </block>
 <block type="mywebsite_catalog/product_new" name="home_products" template="catalog/product/home.phtml">
 <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
 <block type="page/html_pager" name="product_list_toolbar_pager"/>
 <action method="disableViewSwitcher"/>
 <action method="disableExpanded"/>
 </block>
 </block>
 <block type="cms/block" name="cms_content_after">
 <action method="setBlockId">
 <id>another_block_id</id>
 </action>
 </block>
</reference>

Where you break the content into 2 CMS blocks, inserting one above and one below the products block.

answered Dec 21, 2014 at 6:14

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.