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.

How do I show Category Group Names in reverse related entries

March 31, 2010 3:19pm

Subscribe [1]
  • #1 / Mar 31, 2010 3:19pm

    ImpGabe

    171 posts

    How do I filter reverse related entries by category group. I’d like a Category Group Name as a header for a sub nav.
    So for instance, the categories are split into DNA and RNA services. Those are the two category groups. But I can’t figure out how to call just one group in a reverse related entries call.

  • #2 / Mar 31, 2010 3:37pm

    ender

    1644 posts

    I don’t think you can access any category data through the reverse_related_entries tag.  As far as I know, in order to achieve this functionality you’d need a custom query.

  • #3 / Mar 31, 2010 3:38pm

    ImpGabe

    171 posts

    I found a way to do it although it’s not pretty. If anyone else has a more elegant solution, I’d like to hear it.

    DNA
      {reverse_related_entries}
      {categories limit="1"}{if category_group == "2"}{/categories}
        <li><a href="http://{url_title_path=services/category}" title="{categories}{category_name}{/categories}">{categories backspace="2"}{category_name} - {/categories}</a></li>
        {/if}
      {/reverse_related_entries}
      
      RNA
      {reverse_related_entries}
      {categories limit="1"}{if category_group == "3"}{/categories}
        <li><a href="http://{url_title_path=services/category}" title="{categories}{category_name}{/categories}">{categories backspace="2"}{category_name} - {/categories}</a></li>
        {/if}
      {/reverse_related_entries}
  • #4 / Mar 31, 2010 3:55pm

    ender

    1644 posts

    I’m shocked that that does anything, much less what you want it to do 😛

    If it works and performs quickly enough I’d just leave it be.  The more elegant alternative would be in the form of custom queries and possibly some plugin or PHP logic. It wouldn’t be awful to write, but it’d take some time so unless there’s a compelling reason not to use what you’ve got… ya know 😉

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

ExpressionEngine News!

#eecms, #events, #releases