开发者

Specify Category specific layout updates without using Magento's administration dashboard

Is there a way to specify a layout update for a specific category (e.g. using category ID) without hav开发者_运维知识库ing to use the administration dashboard, and setting a [Custom Design > Custom Layout Update].

I am sure I can create a module that looks for a category ID and switches the layout based upon that, but I was curious if there was a naming or some other type of convention for layout files that allows for this type of granular control since Zend Framwork sometimes allows such naming conventions.

Also maybe within the catalog.xml file itself there are additional "layouts" that allow such granularity, something more specific than <catalog_category_layered />


In a standard Magento install (1.4.2, but it should apply to the rest), Magento issues the following Layout handles (handles tell Magento which Layout Update XML Fragments to load from the Package Layout)

<default />
<catalog_category_layered_nochildren />
<STORE_default />
<THEME_frontend_default_default />
<catalog_category_view />
<catalog_category_layered />
<CATEGORY_4 />
<customer_logged_out />

The following layout handle

<CATEGORY_4 />

is generated based on the ID for a category. This means you should be able to add something like the following to your local.xml, or to a custom layout XML file added via a custom module

<layouts>
    <CATEGORY_4>
        <!-- your UPDATE xml here -->
    </CATEGORY_4>
</layouts>


When visiting a catalog category, Magento loads a handle for CATEGORY_${ID}, which you can use to do exactly what you are asking.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜