What is best practice for working with Categories in ExpressinEngine?

馋奶兔 提交于 2019-12-23 07:56:10

问题


I'm working on my first eCommerce site using the "store module". We have around 25 categories that each product can be categorized by. This is my first time working with so many categories.

Most of the product selection area will be using one template. I have a couple of questions regarding the use of categories. I will list them below. Any insight into what the best approach is, would be most appreciated. I'm not even sure If i'm doing this correctly. I'm kinda of fumbling my way through this one. LOL.

Question 1

When I create links for each of the parent categories (ie. Central Vacs, Portable vacs, etc.), should I be using the URL to call on the category to display product in this category or is there a dynamic way of creating the links?

Question 2

If you have selected a parent category (ie. Central Vacs, Portable vacs, etc.) I would like all child categories of this group to be displayed in the side menu (ie. Power, colour, etc.). Is the best way to achieve this done by using the URL segment to show the child categories?

I really want to make sure that if a user is displaying "Portable Vacuums" that all of the side menu navigation is related to that category only (ie. display child categories for this Parent)

Thanks in advance


回答1:


Question 1. When I create links for each of the parent categories (ie. Central Vacs, Portable vacs, etc.), should I be using the URL to call on the category to display product in this category or is there a dynamic way of creating the links?

Yes, and there are a variety of ways to dynamically build a linked list of categories. One way is the native Channel Categories Tag

The {category_url_title} and {category_id} variables available within the Channel Categories tag pair can also be useful in building URLs for links.

Alternatively, GWcode Categories is a handy plugin for working with categories and has lots of useful options.

Question 2. If you have selected a parent category (ie. Central Vacs, Portable vacs, etc.) I would like all child categories of this group to be displayed in the side menu (ie. Power, colour, etc.). Is the best way to achieve this done by using the URL segment to show the child categories?

Yes. I'd recommend using a segment containing the category_id or category_url_title as a parameter in GWcode Categories to get the list of children. GWcode Categories has excellent documentation. A basic example:

{exp:gwcode_categories cat_url_title="{segment_3}"}
    {cat_name}      
{/exp:gwcode_categories}            

Another really useful add-on for working with categories is Low Seg2Cat




回答2:


You can output parent categories, child categories and entries posted into child categories by using Child Categories add-on.



来源:https://stackoverflow.com/questions/13101878/what-is-best-practice-for-working-with-categories-in-expressinengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!