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

Can Magento Work With nested Static Blocks? 
 
Mendrel
Jr. Member
 
Total Posts:  23
Joined:  2008-11-05
 

Here’s the deal. We’ve got a bunch of products and most of them have the same information that we display in the right column. In order to make this work for all of our products we need something like the following:

Main Block:
This block is added to all of the products we want

Sub-Blocks:
Within the main block, we have several sub-blocks for groups of information. In one of the blocks, I need to set the path for a specific document. I know I can use some kind of “<url>path/to/file</url>” in the XML. However, this means that this block cannot be a static block (can’t call PHP in the static blocks). So, this must be located within the directory structure, rather than listed as a static block in the backend. Then, in the XML, I just call it with <block type="core/template" ....template="callouts/my_file.phtml"> and the block will show up and I can pass values in with XML updates per product.

Other than that one, I have a static block (named ‘sizes’) and within that block I have two additional blocks (named ‘vertical’ and ‘horizontal’) and within those blocks I have three blocks (’small’,’medium’,’large’). How can I add the main ‘sizes’ block using the XML update then remove a particular sub-block (such as the ‘horizontal’ or the ‘large’ block from the ‘vertical’ block)?

Is there any way to replace a block with another block? For example, one of the items has a different warranty. If ‘warranty_a’ was included in the main block, can I remove it and replace it with ‘warranty_b’ block?

To sum up:
How can I create a series of nested blocks which I can remove sub-blocks using the <remove> action method?
Is there a better template than the left callout to follow for passing data from the XML to be part of the path to a file?
How can you replace a block, within a static block, with another static block?

Issues:
In the XML:

<block type="cms/block" name="my_header" as="my_header" before="some_block">
    <
action method="setBlockId"><id>my_header</id></action>
</
block>

works and it’s possible to remove the element, however:

<block type="cms/block" name="my_header" as="my_header" before="some_block">
    <
action method="setBlockId"><id>my_header</id></action>
    <
block type="cms/block" name="sub_block" as="sub_block">
        <
action method="setBlockId"><id>sub_block</id></action>
    </
block>
</
block>

only renders the ‘my_header’ element. Obviously if I add the ‘sub_block’ data to the ‘my_header’ static block it will appear...but then you can’t use <remove> to drop the element.

So, I’m confused what the proper way is to get nested blocks to appear so that they can be removed from the block if needed using the Layout Update XML. I’ve tried using various combinations of insert/append and unsetChild/remove but still haven’t stumbled across how to manage static blocks in this manner.

Help? smile

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