0

I am looking into the application flow to see how the products are getting rendered on a product listing page.

url : catalog/category/view/id/6

In viewAction, there is this line

$update->addHandle('CATEGORY_' . $category->getId());

means CATEGORY_6 in my case.

Now, where is this block in Layout.xml(I know it's dynamic) but what this handle does? So that I can check what blocks it is rendering.

1
  • you can take a look into observers, where these handles will be processed. observers are assigned in config.xml of corresponding module
    – Shathish
    Jun 14, 2013 at 6:01

1 Answer 1

2

In a clean Magento instance this layout does not exist. This is a feature that allows you to change the category layout as you want just by adding blocks to this layout handle. You can add something like this in one of your theme layout files.

<CATEGORY_6>
    <reference name="content">
        <block type="core/template" template="path/to/template.phtml" />
    </reference>
</CATEGORY_6>

The layout above will add a block with the template path/to/template.phtml on your category page (with ID 6).

If you want to take a look at what blocks are rendered in a page you can identify the default handle for that page like this. If the url to the page is module/controller/action/param1/value1/param2/value2 the layout handle for it would be <module_controller_action>.
For categories there is an other layout that is loaded depending on how many child categories the main category has. If it has no children than this will also be loaded <catalog_category_layered_nochildren>.

On other layout handle loaded depends on the is_anchor attribute of the category.
This comes from $update->addHandle($category->getLayoutUpdateHandle()); And Mage_Catalog_Model_Category::getLayoutUpdateHandle() looks like this:

public function getLayoutUpdateHandle()
{
    $layout = 'catalog_category_';
    if ($this->getIsAnchor()) {
        $layout .= 'layered';
    }
    else {
        $layout .= 'default';
    }
    return $layout;
}

If is_anchor is Yes then the layout handle added is catalog_category_layered. Otherwise catalog_category_default is loaded.
[EDIT]
Also, what you add to the category from the admin panel under Display settings is added to the layout.

2
  • I've not tested but from this I can assume that what ever we're going to put in custom design in manage category admin, it will eventually comes under this handle for that particular category Id. Is it? Jun 14, 2013 at 7:10
  • What you put in the admin form of the category is also loaded when displaying the page, but it's not added to a layout handle. It's treated separately. I edited my answer and added this also.
    – Marius
    Jun 14, 2013 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.