I think my categories are messed up. I simply dont know how to set them up for this now. I cant use the same cat name …. like
I have categories like:
18 | industry 17 | top-level
Now inside top level:
116 | consumer | consumer 111 | food |food 112 | industrial | industrial
Inside “industry:
120 | industrial | 119 | |__anti-static bags | 114 | |__box liners | 115 | |__bubble bags | 121 | food |
if I try to add anti-static bags under food, it wont work
So this means I need to break out the industrial / food / consumer to their own separate category.
template one: (index) http://localhost/mysite/index.php/products/
{if segment_2 == ""}
{exp:channel:categories channel="products" category_group="17"}
<a href="http://{path=products/industry}">{category_name}</a>
{category_description}
{/exp:channel:categories}
{/if}Here I see the top three (consumer, industrial, food)
page 2 (industry) http://localhost/mysite/index.php/products/industry/category/industrial
{exp:gwcode_categories cat_url_title="{segment_4}"}
{cat_name}
{/exp:gwcode_categories}This page is supposed to spit out the child cat of the top level… I think. but I cant set it up because I cant have duplicate names under parts in one category
Ahhh…. i think im starting to see the light here.
So… I have 3 pages
Template group = products Templates under products = index, industry, detail
============ index: http://localhost/mysite/index.php/products/
{if segment_2 == ""}
{exp:channel:categories channel="products" category_group="17"}
<a href="http://{path=products/industry}">{category_name}</a>
{category_description}
{/exp:channel:categories}
{/if}=========== Industry Page: http://localhost/mysite/index.php/products/industry/category/industrial
{if last_segment =="food"}
{exp:gwcode_categories cat_id="120"}
{cat_name}
{/exp:gwcode_categories}
{/if}
{if last_segment =="industrial"}
{exp:gwcode_categories cat_id="119" incl_self="no"}
<a href="http://{complete_path}">{cat_name}</a>
{/exp:gwcode_categories}
{/if}========== Detail Page
{exp:channel:entries channel="products" disable="pagination"}
<strong>{title}</strong>
{description}
{product_details}
{product_details:item_no}
{product_details:size}
{product_details:mil} -
{product_details:weight} -
{product_details:quantity} -
{product_details:color}
{/product_details}
{/exp:channel:entries}So.. the link to the details… my url structure seems a bit wonkey
The product page is: http://localhost/mysite/index.php/products/
When I click on industrial, I get: http://localhost/mysite/index.php/products/industry/category/industrial
When I click a link from here, lets say box liners, I get this http://localhost/mysite/index.php/products/industry/category/industrial/ind-box-liners
Should this last page link to details? That last URL should just list product name…. then clicking the name = details.
Getting close..
Closer, but again if you find yourself looking to use conditionals against specific ID’s - stop. That’s a rabbit hole you don’t want to go down. Bad things live there.
Instead of
{if last_segment =="food"}
{exp:gwcode_categories cat_id="120"}
{cat_name}
{/exp:gwcode_categories}
{/if}
{if last_segment =="industrial"}
{exp:gwcode_categories cat_id="119" incl_self="no"}
<a href="http://{complete_path}">{cat_name}</a>
{/exp:gwcode_categories}
{/if}Try
{exp:gwcode_categoriescat_url_title="{segment_4}" incl_self="no"}
<a href="http://{complete_path}">{cat_name}</a>
{/exp:gwcode_categories}If you want a product-specific detail page then sure, link to that last.
I actually tried that, and it only returns the top level cat, and doesn’t show the the sub-cats under it.
for example, if my URL is: http://localhost/mysite/index.php/products/industry/category/food
All I see is “food” and thats it.
If I wrap it in the if statement, using the direct cat_id, I get the desired result.
I would prefer to segment_4, but it wasn’t working. :/
Keep trying…;)
You shouldn’t have to wrap it in conditionals. You should be able to feed GWCode which categories you want subcategories for dynamically. The docs show it. If you have the categories configured correctly in EE (and aren’t using separate groups any more) and it doesn’t work I’d be contacting the dev for support.
how does one actually go about displaying entries associated with the sub-cats?
I kinda got this limping along.
page one, the products, I ended up hard-coding the top level links because using categories to populate this particular menu was adding “category” to my URL, and I didnt want that using this plugin
So, page one, hard-coded links:
<a href="http://{path=products/industry/consmer}"> consumer</a>
<a href="http://{path=products/industry/food}"> food </a>
<a href="http://{path=products/industry/industrial}"> industry </a>Now, on the industry page, I have
{exp:gwcode_categories cat_url_title="{segment_3}" entry_count="yes" show_empty="no"}
<a href="http://{cat_url_title}">{cat_name}</a> ({entry_count})
{/exp:gwcode_categories}This is good so far. I now have these sub cat’s listed out, and I can see how many products are associated to them by the plugins “entry_count” function.
I’m unsure how the detail page fits in now, with this plugin… because at this point, I need to list out the title of each product as a link …. that when clicked, shows it’s detail. (client wants only one product per page, not a list)
seems like I should be passing the cat_id off to the channel entry somehow. Ive tried a few things but im not getting the desired results. cat_id wont work in the channel entry, if that makes sense
So the key thing is that by choosing to remove /category/ from the URL you’ve stepped outside of how EE natively works with categories.
The channel:entries tag knows which entries to load by the URL structure. So if it sees a URL ending in /category/category-url-title/ it will automatically/dynamically pull entries assigned to that category (this is why category url titles need to be unique).
But you’ve now stripped it of that automation and need to force-feed the category somehow. The options that come to mind are either to put /category/ back in the URL or use LowSeg2Cat to grab a caetgory url from a url segment and feed it to channel entries tag.
http://gotolow.com/addons/low-seg2cat
And again, the reason for all of this is that categories were not designed to drive heirarchical navigation like this. They were intended to be simple filters on a blog. Granted they are long-overdue for some updates.
ahhh.
ok i understand. This puts me in a catch 22. I’ve made progress in the direction I want to go in, and at the same time have successfully disabled the ability to link to an actual entry. LOL
If i add category to the URL, the plugin doesnt work.
If I remove it, I need to somehow use seg2cat in the channel entry to pull the entry titles and list them out so the user can be taken to a detail page.
back to the grind….
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.