2

Within my exp:channel:entries tag, I am using the categories tag pair to show the categories that the entry is in. However, it is only showing the last category that the entry is in:

{exp:channel:entries}
    <h3><a href="{url_title_path='photos'}">{title}</a></h3><br />
    {image_upload}
        <img src="{path}_thumbs/{filename}.{extension}" />
    {/image_upload}
    <a href="{url_title_path='photos/printing'}">Print this photo</a><br />
    Categories: {categories backspace="2"}{category_name}, {/categories}<br />
{/exp:channel:entries}

This is the same on both the development and live sites.

There are a number of categories in the database (a couple of hundred), but each entry is only in around 2 or 3 categories. The correct categories are all selected when editing the entry in the admin panel.

4
  • 1
    What happens when you add the channel parameter in the exp:channel:entries tag with the correct channel name?
    – Siebird
    May 21, 2013 at 13:18
  • @Siebird - no difference May 22, 2013 at 10:53
  • It's a good idea to always specify channel - otherwise EE will pull from all channels in the system. What URL is this page appearing at? What happens if you pull off the backspace parameter on the categories loop? Anything different if you strip out everything to just title and category? May 23, 2013 at 3:13
  • Tried all those things, no joy unfortunately. The problem appears at different URLs on the development and live sites. Jun 11, 2013 at 9:16

1 Answer 1

4

I've discovered the cause:

The channel entries and categories are added through a web service, and it turns out I missed the exp_category_field_data table.

Without anything in this table, only the last category was showing. I've updated the web service to add the categories to this table, and it's working correctly now.

2
  • Grr I hate EE sometimes -- they make it so difficult to import data cleanly. Mar 24, 2014 at 3:06
  • 2
    If you don't need category fields, your web service can ignore the exp_category_field_data. Just make sure your {exp:channel:entries} tag has disable="category_fields" and all of the categories will show up. Oct 15, 2014 at 19:27

Your Answer

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

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