For this project I have categories, subcategories and products. I am displaying the categories on 1 template (index) and the subcategory on another template (list),
and the products belonging to that subcategory on another template (prod-list) and a detailed description of the product on another template called (detail). All templates
are in the same template group (products).
1 Weblog called “products”
1 Category Group assigned to Weblog “prodcuts” with following structure:
LEVEL1 Fruit
LEVEL2 Apricot
LEVEL2 Cherry
LEVEL2 Citrus
LEVEL1 Vegetables
LEVEL2 Beans
LEVEL2 Beets
LEVEL2 Carrots
I template group (products) with the following templates:
index
list
product-list
detail
I use 2 plugins: child categories and category id
The index template displays the 2 LEVEL1 categories: Fruit and Vegetables
{exp:weblog:categories weblog=“products” parent_only=“yes” style=“linear”}
<li class=“left-img left-img-2”><a href=”{path=products/list}”>{category_image}{category_name}</a></li>
{/exp:weblog:categories}
When I click on the fruit or vegetable link in the index template I link to
“list” template and display the LEVEL2 sub-categories: Apricot, Cherry, Citrus.
I am using the category ID plugin to call my category name from segment_4 and convert it into an ID for the category_id. This works fine.
{if segment_4!=”“}
{exp:category_id category_group=“3” category_url_title=”{segment_4}” parse=“inward”}
{exp:child_categories parent=”{category_id}” child_categories_sort_direction=“asc” show_empty=“yes” entries_sort_direction=“asc” parse=“inward”}
{child_category_start}
<li class=“left-img left-img-2”><a href=”{path=products/prod-list/{parent_category_url_title}/{child_category_url_title}}”><img src=”{child_category_image}” width=“141” height=“140” alt=”{child_category_name}
title=” />{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
{/exp:category_id}
{/if}
When I click on one of the sub-categories from the “list” template, I link to another template called “product-list” which should display all the products assigned to this sub-category. At this point I am stuck.
I tried to pass the {parent_category_id} and {child_category_id} into the url and again grab it from the segment. However, this approach doesnt seem to work.
{if segment_3!=”“}
{exp:category_id category_group=“3” category_url_title=”{segment_3}” parse=“inward”}
{exp:child_categories parent=”{category_id}” child_categories_sort_direction=“asc” show_empty=“yes” entries_sort_direction=“asc” parse=“inward”}
{child_category_start}
<li class=“left-img left-img-2”><a href=”{path=products/details}”><img src=”{child_category_image}” width=“141” height=“140” alt=”{child_category_name}
title=” />{child_category_name}</a></li>
{child_category_end}
{/exp:child_categories}
{/exp:category_id}
{/if}
My last step will be to display a detailed prodcut description. This will link to the “detail” template.
I am not sure if I am going about this the correct way. Is there a mistake in my code or should I structure/rethink my approach? I would appreciate some pointers.
thank you very much,