We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Structure module - categories

Development and Programming

code72's avatar
code72
104 posts
16 years ago
code72's avatar code72

@rockthenroll I’ve tested it several category levels deep and it seemed to work fine. However I haven’t yet tested it with deeper segment levels or anything more complex yet.

       
code72's avatar
code72
104 posts
16 years ago
code72's avatar code72

With a slight tweak you can also get it to work with pagination:

{exp:weblog:entries weblog="blog" limit="2" dynamic="{if segment_2 == ''}off{/if}{if segment_2 != ''}on{/if}" disable="member_data|trackbacks"}
       
barthoub's avatar
barthoub
63 posts
16 years ago
barthoub's avatar barthoub

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?

       
code72's avatar
code72
104 posts
16 years ago
code72's avatar code72

I think you’re right, it won’t work in that scenario because with dynamic=”on” EE uses the URL to figure out what content to pull. If you need a different URL structure, you’d have to figure out some sort of work around whether you used structure or not.

       
patrick-vibes's avatar
patrick-vibes
63 posts
15 years ago
patrick-vibes's avatar patrick-vibes

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/

       
rockthenroll's avatar
rockthenroll
485 posts
15 years ago
rockthenroll's avatar rockthenroll

@patrick-vibes Thanks for sharing, this is AWESOME. Definitely something we need to work through a bit more. I just wish this would work with dynamic categories and you didn’t need a page for each category. Great solution though!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
15 years ago
Mark Bowen's avatar Mark Bowen

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

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.