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

Any way to have more than 1 conent block per page? 
 
GregC
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2007-11-23
A^2, MI
 

I’m trying to understand the template system and not getting very far. 

Most of this revolves around not knowing what the <action> elements in a <block> really mean.

For example, I’d like to be able to add additional content blocks on the category landing pages.  These blocks could be used as banner ads or sale item kickers.  I was hoping that they could be edited separately from the main content on the page, which rarely changes.

I thought that you’d just add this kind of content as a block element in the template for a category page and that there would be some sort of action to read from the CMS static blocks.

I figure this is pretty basic functionality, so I just must not be getting how to do it.

I read the guides and the wiki and understand the main concepts of the layout XML, but I clearly don’t understand all of the options available for the <action> tag.  Is there a list of methods options somewhere?  Is what I’m planning even possible - or the right way to do it - in this version of Magento?

Thanks for the assist,

Greg

 
Magento Community Magento Community
Magento Community
Magento Community
 
GregC
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2007-11-23
A^2, MI
 

OK..Ok..ok

I’ve hacked ‘round a bit and discovered that you can set up a block like -

<reference name="left">
                <
block type="cms/block" name="your_block_name">
                    <
action method="setBlockId"><block_id>your_CMS_block_identifier</block_id></action>
                </
block>
        </
reference>

so now I’m off and running again. 

GregC

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

you can include additional static cms blocks by adding this in the Custom Layout XML for the category:

<reference name="content">
  <
block type="cms/block" before="-">
    <
action method="setBlockId"><id>block_identifier</id></action>
  </
block>
</
reference>
where before="-" means it should be before any previously created blocks in “content”, and block_identifier is the Identifier you have used for your CMS block.

the <action> tag basically runs a PHP method on the block. So the layout update above is equivalent to:

<?php
$layout 
Mage::registry('action')->getLayout();

// <reference name="content">
$contentBlock $layout->getBlock('content');

// <block type="cms/block" ...
// var $cmsBlock Mage_Cms_Block_Block
$cmsBlock $layout->createBlock('cms/block');

// <action method="setBlockId"><id>block_identifier</id></action>
$cmsBlock->setBlockId('block_identifier');

// ... before="-">
$contentBlock->insert($cmsBlock"-");
 
Magento Community Magento Community
Magento Community
Magento Community
 
GregC
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2007-11-23
A^2, MI
 

Thank you. 

Now I’m moving on to figuring out how to add my own templates (1 col with kickers, 2 col with kickers, etc).

More questions to follow wink

Greg

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