0

I'll try to explain it. Here we go.

Searched all over the web but got nothing.

I've got a setup where no category is used in the URL. Navigation is build with stucture. I've got a channel with entries which do have a category.

When I create a entry with structue I assign a category as well. You'll get something like this in stucture:

Locations - Location A (has template X and category Y) - Location B (has template X and category Z)

Now the url looks something like this: www.website.com/locations/location-a/ www.website.com/locations/location-b/

I don't know the category. But I do want to display the entries which belong to the Location with category Y or Z.

The solutions I've tried all need the cat name or id in the URL

It could be that I'm looking at it the wrong way. Hope someone can help me or point me in the right direction.

Cheers, Martijn

2
  • Does this help - gives you all categories for an entry: stackoverflow.com/questions/8432547/… Jul 3, 2013 at 9:23
  • Nope. I need to know the category in order to output the entries. Example: {exp:channel:entries channel="location" dynamic="no" category="{cat}"}. Where {cat} is de category which I must get from somewhere
    – Sharkbyte
    Jul 3, 2013 at 9:49

3 Answers 3

1

I'm not sure I understand what you're trying to achieve. Have you looked at any of these addons to see if they can do what you want:

URL Segment tom-foolary:

Full on routing

I've not used any of the routing addons in production but they look pretty solid.

0

If you have the channel entries tag around your content, calling in the entry, than adding channel="locations" and category="#ID | #ID" where #ID is the id of the category, than it should do it. http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#category

OR if it is more complex...

I believe that you can use gw:code (http://gwcode.com/add-ons) to grab the category group or category id's in your Entry Parameters to narrow down your returns, check out the documentation and examples in each addon to see which one may work best for you, I think 'gw:categories' should do it.

1
  • Tnx, I'll take a look at GWCode. That just might do it. I'll let you know.
    – Sharkbyte
    Jul 18, 2013 at 10:46
0

Are you looking for something like this?

{if segment_2 == "location-a"}

  {exp:channel:entries channel="location" dynamic="no" category="cat-y"}
  ...
  {/exp:channel:entries}

{if:elseif segment_2 == "location-b"}
  {exp:channel:entries channel="location" dynamic="no" category="cat-z"}
  ... 
  {/exp:channel:entries}

{if:elseif segment_2 == "location-c"}
  {exp:channel:entries channel="location" dynamic="no" category="cat-y|cat-z"}
  ... 
  {/exp:channel:entries}

{/if}
1
  • Yes, I've used something like this before. But my clients is able to add Locations and doesn't want to call me to alter the templates every time. But basically this is what I trying to accomplice.
    – Sharkbyte
    Jul 18, 2013 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.