This works when your structure is the same as your template structure.
If your template is called ‘news’ and your structure page is called ‘news’ this does the trick, but when this isn’t the same I think this workaround does not work. Or am I missing something?
Can somebody help me with this?
After some serious issues with getting categories to work I believe I have found a relatively simple solution, I might be wrong and might be retreading something someone else has covered if so I do not intend to steal credit but figured I would post exactly how I setup categories to work.
For the store I am building I have a parent page in structure called “clothing” which acts as a landing page to choose “mens” or “womens” (parent categories respectively).
The products listing page is a template called “products” which you are taken to once you select a parent category so the url is:
myshop.com/index.php/clothing/products/mens
The link to achieve the above is
<a href="http://{path=clothing/products/{category_url_title}}">{category_name}</a>On the “products” (listing) page I am then pulling in the products by category using the following code:
{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_3}'"}
{exp:weblog:entries weblog="products" category="{cat_id}" dynamic="off" orderby="title"}
{blah blah info}
{/exp:weblog:entries}
{/exp:query}It works a treat so far as I can tell just trying out all the categories, and just to recap my template structure and “Structure” setup:
STRUCTURE - clothing (template is clothing/index)
*I have Structure set to use ‘clothing/detail’ as the single item view page
TEMPLATES - clothing/index - clothing/products - clothing/detail
I hope this a) continues to work as I build the store and b)if so then these instructions help others out there, a great aspect of this approach is there is no category trigger in the url so it’s shorter (i.e. no ‘/category/’).
Credit duely noted to the 47media entry on removing the category url indicator see here: http://fortysevenmedia.com/blog/archives/setting_up_custom_category_url_structures_in_expressionengine/
Hiya,
Don’t forget to take a look at the Low Seg2Cat extension as then you should be able to get rid of that SQL query and use the extension instead.
Pretty sure that should work in this case anyway.
Hope that helps a bit.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.