Skip to content

New handles for the Category, Product and CMS pages #102

Closed

Description

@paales

Add handles to category page

If you are viewing a category: /products/dvds.html (category id: 5)

You'll get a handle by default: CATEGORY_5

We add the following:

Handle: CATEGORY_2_child_child

Category 2 is the root category for this store, so allows for store specific configuration. If the category path is
longer it will show something like CATEGORY_2_child_child_child

Handle: CATEGORY_2_child_dvds

This one is kinda cool, this one allows you have one layout for multiple childcategories. Imagine the following categories:

  • /playgroup/books.html
  • /kindergarten/books.html
  • /elementary/books.html

All these categories will have the CATEGORY_2_child_books handle, so you can all style them the same!

Handle: CATEGORY_3_child

Child of a certain category.
If the category path is longer it will show something like CATEGORY_3_child_child.

Add category handle to product page.

The same as for the category applies, except everything is prefixed with PRODUCT_CATEGORY_ instead of CATEGORY_.

Add attribute set handle to product page

PRODUCT_ATTRIBUTE_SET_default

For styling based on the attribute set handle.

Add handles to CMS page

If you have the page: customerservice/faq/question_one, you'll get the following handles (same idea as for the categories):

CMS_PAGE_customerservice_child_child
CMS_PAGE_customerservice_faq_child
CMS_PAGE_customerservice_faq_question_one

Activity

  1. magento-team commented on Jan 11, 2013

    @magento-team
    Contributor

    Hi. Thank you for your proposal.
    We can implement most of the ideas, but with some modifications.
    Here is major resolution:

    Add handles to category page:
    "CATEGORY_2_child_child" will be transformed to "catalog_category_view_id_2_child_level_2"

    "CATEGORY_2_child_dvds"
    It's bad practice to make dependance on user input at handle (category name in this case). To apply some layout update to few dvd categories you can reorganize your catalog or make updates for few handles. Will it work for you? If no, can you propose alternative way without using category name for layout handle?

    Add category handle to product page:
    "PRODUCT_CATEGORY_" => "catalog_product_view_category_id_"

    Add attribute set handle to product page:
    "PRODUCT_ATTRIBUTE_SET_default" - same situation as with category name. Better to use attribute set id for handle: "catalog_product_view_attribute_set_id_1"

  2. paales commented on Jan 11, 2013

    @paales
    ContributorAuthor

    Thanks for responding and implementing this feature :)

    It's bad practice to make dependance on user input at handle (category name in this case). To apply some layout update to few dvd categories you can reorganize your catalog or make updates for few handles. Will it work for you? If no, can you propose alternative way without using category name for layout handle?

    That requires me to update the XML for each new category (admin, files, doesn't matter, will have to update somewhere), think that solution is a bit less smooth (especially with automatic imports), but I don't really have a better solution.

    The other suggestions are fine, dont really care how they are written down, just that they are :)

  3. amenk commented on Jan 14, 2013

    @amenk
    Contributor

    Cant we have an attribute in categories that let's us specify a category-handle manually? I know, it is still user input - but then it would be clear, that the input affects the layout.

  4. paales commented on Jan 14, 2013

    @paales
    ContributorAuthor

    Cant we have an attribute in categories that let's us specify a category-handle manually? I know, it is still user input - but then it would be clear, that the input affects the layout.

    There really isn't that much difference to require someone to copy some XML or to copy some string:

    Example XML (this is for Magento 1, but I think Magento 2 will be about the same):

    <update handle="catalog_category_my_custom_handle" />
  5. magento-team commented on May 13, 2013

    @magento-team
    Contributor

    The Technical Task created to resolve this problem.

  6. added a commit that references this issue on Feb 20, 2015
  7. added a commit that references this issue on Nov 3, 2015
  8. added a commit that references this issue on Jul 19, 2016
  9. added a commit that references this issue on Apr 13, 2018
  10. added a commit that references this issue on Oct 12, 2019
  11. ilnytskyi commented on Sep 24, 2020

    @ilnytskyi
    Member

    Not sure what it was like in 2012 but that would be nice to have possibility to disable additional (product_id,sku/category_id) handles.
    Check my comment #189 (comment)
    Now we have thousands of entries in the cache storage that we do not need...

  12. paales commented on Sep 24, 2020

    @paales
    ContributorAuthor

    @ilnytskyi Wow, that is an old issue! I don't thing you'll get any meaningful response. In 2012 this looked like a great idea, but not so much any more ;)

  13. ilnytskyi commented on Apr 24, 2021

    @ilnytskyi
    Member

    When we removed entity ids from layout handles. We reduced used cache space significantly and it also improved overall page performance.
    Selection_639

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for development

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions