2

I have a "featured item" part on my site that is controlled with a new status i created called "featured". I have 8 parent categories, and would like to have 8 different featured items, 1 unique for each category parent.

I am trying to make this dynamic so when I click on my category "central vacuum", then the item that is under the category central vacuums and has a status of featured to show.

I have come across a solution, which is to create 8 different statuses and then write 8 if statements, but I know theres another way around it I just can't seem to find one.

{exp:channel:entries channel="products" status="featured" limit="1" category_id="{segment_3}"}
     <img src="{feature_image}"/>
{/exp:channel:entries}
4

If you're displaying your categories using standard category URLs (e.g., /products/category/central-vacuum or /products/C12), then you only have to add the status parameter to your Channel Entries tag (the category will be filtered dynamically based on the URL).

{exp:channel:entries channel="products" status="Featured"}
...
{/exp:channel:entries}

So in the example of the URL /products/category/central-vacuum, the code above would pull only products in the Central Vacuum category with Featured status.

| improve this answer | |
  • Perfect, that did it. I removed the dynamic="no", removed any if statement I had, and made status="featured" category_id="{segment_3}". But now i've run into another problem. This is only working for the Parent categories. Is there a way to have all child categories the same feature as the parent category. I'm trying to show the same feature item for all the children within the parent. Thanks in advance! – Funkefied Dec 17 '12 at 21:29
  • Glad to hear it. By default, EE assigns all child categories to their parent category as well. So remove category="{segment_3}" and it should work exactly how you want (so long as you're using dynamic URLs as I described above). – Derek Hogue Dec 17 '12 at 21:41
  • For some reason it's not working without {segment_3}. I posted a small snippet in my original post of my entry code that's pulling it in. Thanks again, you've been great help! – Funkefied Dec 17 '12 at 21:59
  • What does your URL look like? Are you using an add-on that manipulates segments like Structure? – Derek Hogue Dec 17 '12 at 22:02
  • after my .com it's (index.php/products/c/central-vacuum-canisters) and I'm not using any add-on manipulating segments. – Funkefied Dec 18 '12 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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