Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

magento

Is there a way to specify a layout update for a specific category (e.g. using category ID) without having 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 />

like image 601
Anthony Avatar asked May 16 '11 18:05

Anthony


1 Answers

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>
like image 63
Alan Storm Avatar answered Sep 30 '22 17:09

Alan Storm