ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

A category question...

May 31, 2011 12:51pm

Subscribe [2]
  • #1 / May 31, 2011 12:51pm

    FaithBuilders

    42 posts

    I’m having trouble getting my category-based content to appear. I have a product page that displays one entry, like a single book or DVD. On this product page I have a series of conditional statements under the product images and description:

    {if '{categories}{category_url_title}{/categories}' == 'books'}
               {embed="includes/details_books"} 
                  {/if} 
    
     {if '{categories}{category_url_title}{/categories}' == 'audiobooks'}
               {embed="includes/details_audiobooks"} 
                  {/if}

    There are several more of these statements, one for each category (books, dvds, etc.) in the “products” channel.

    This product template accurately displayed the embedded category content until I added another level of subcategories. Now, instead of only having books, dvds, etc., I have Books - Foundation Series, Books - Discipleship Series, etc.

    The statements no longer display the category-specific content.

    I tried replacing the ‘books’ in the statement with ‘books_foundation_series’, which is a sub-category name, but it doesn’t seem to display the embedded content.

    Any ideas on how to display the content based on the parent category, even though the product is also in a lower sub-category?

    Your help is greatly appreciated!

    ~Sarah

  • #2 / May 31, 2011 1:55pm

    Kernon

    173 posts

    You might consider using the parent_id instead of the url title.  Or, another thing to try would be adding limit=“1” to the categories tag.

  • #3 / May 31, 2011 3:37pm

    FaithBuilders

    42 posts

    Thank you for responding! I tried both of your suggestions. However, they seemed to make no difference. The content still does not appear if the item is in a sub-category.

  • #4 / May 31, 2011 4:09pm

    Kernon

    173 posts

    Sorry about that, I was just guessing at what might help.  I can’t test your exact situation, but when I fooled around with using limit=1 it seemed to do what I expected.

    Have you tried running a test template and seeing what is being output?

    Another approach would be a plugin, but I don’t have the reference handy.

  • #5 / May 31, 2011 5:01pm

    FaithBuilders

    42 posts

    Kernon, you will now know that I am a true novice with ExpressionEngine. I was still trying to use the category name with the parent id:

    {if '{categories}{parent_id}{/categories}' == 'books'}

    That’s why it wasn’t working. I switched it to the actual id #, instead of ‘books’, and it worked.

    Thank you for your help!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases