1

Looking in app/design/frontend/base/default/layout/catalog.xml, I see what appears to be conditional XML based on product type.

<!--
Additional block dependant on product type
-->
    <PRODUCT_TYPE_simple translate="label" module="catalog">
        <label>Catalog Product View (Simple)</label>
        <reference name="product.info">
            <block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="catalog/product/view/type/default.phtml">
                <block type="core/text_list" name="product.info.simple.extra" as="product_type_data_extra" translate="label">
                    <label>Product Extra Info</label>
                </block>
            </block>
        </reference>
    </PRODUCT_TYPE_simple>
    <PRODUCT_TYPE_configurable translate="label" module="catalog">
        <label>Catalog Product View (Configurable)</label>
        <reference name="product.info">
            <block type="catalog/product_view_type_configurable" name="product.info.configurable" as="product_type_data" template="catalog/product/view/type/default.phtml">
                <block type="core/text_list" name="product.info.configurable.extra" as="product_type_data_extra" translate="label">
                    <label>Product Extra Info</label>
                </block>
            </block>
        </reference>
        <reference name="product.info.options.wrapper">
            <block type="catalog/product_view_type_configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="catalog/product/view/type/options/configurable.phtml"/>
        </reference>
    </PRODUCT_TYPE_configurable>

How is this logic accomplished? Can these keywords be used in any layout files?

  • When layout XML is invoked for rendering, all layout XML files' contents are evaluated. Consider them all as one container; it's the layout update handles (including the ones you've noted) which are used for scoping purpose. – benmarks Jan 8 '14 at 23:40
3

This "logic" are standard layout handles.

They are added here:

\Mage_Catalog_Helper_Product_View::initProductLayout
...
$update->addHandle('PRODUCT_TYPE_' . $product->getTypeId());
$update->addHandle('PRODUCT_' . $product->getId());
...

And yes, they can be used in every layout file. But I recommend to use a local.xml instead of changing the layout.xml files of the core - but this topic is a minefield ;-)

| improve this answer | |
  • Thanks Fabian. Not changing core files, but building my own based on them. =D – Ryre Jan 8 '14 at 23:12
  • I know what you mean, you copy the catalog.xml to your theme - I don't like this approach, because you get lots of problems after an update. the advantage is, you don't get all the new features after an update and the update doesn't crash your design, but maybe functionality ;) – Fabian Blechschmidt Jan 8 '14 at 23:34

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.