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.

Complex relationships: how best to handle?

September 17, 2007 4:18pm

Subscribe [2]
  • #1 / Sep 17, 2007 4:18pm

    ee4me

    31 posts

    On a magazine website, I have an issues weblog, articles weblog and authors weblog.

    An article record has three relationship fields:

    rel. field: article_issue, child: issues weblog
    rel. field: article_author1, child: authors weblog
    rel. field: article_author2, child: authors weblog

    I need to be able to pull a list of articles for a given issue, and get at the authors as well.

    The following pulls the issue month/year (issues weblog {title}) and articles perfectly, but doesn’t pull the author data:

    {exp:weblog:entries weblog="issues"}
    {title} Issue
    
    {reverse_related_entries weblog="articles"}
    
    {title}
    {article_subtitle}
    
    {related_entries id="article_author1"}
    by {author_first_name} {author_last_name}
    {/related_entries}
    
    {related_entries id="article_author2"}
    and {author_first_name} {author_last_name}
    {/related_entries}
    
    {/reverse_related_entries}
    
    {/exp:weblog:entries}

    It appears that the related_entries tags don’t work inside the reverse rel. tag, as I am getting screwy “{REL[article_author1]TdcZdc1vREL}” garbage on my screen. Perhaps this is the real problem?

    I tried an exp:query next, but found that related_entries don’t work inside the query tags! Again, can someone please confirm this? I’m unable to find any info in the docs.

    So is there a better way to accomplish this page? I’m eyeing a huge, nasty query to pull all the related data out, and would rather not go there if there’s another way.

    EE 1.6.0

    Thanks!

  • #2 / Sep 17, 2007 5:56pm

    ee4me

    31 posts

    OK, I was able to accomplish a fix with a small embedded template as detailed here.

    I would still like to know if there’s a better way to handle this.

    I’d also like to propose that the docs get updated. In the thread linked to above, Robin Sowell’s remark, “Hm- you’re right in that you can’t use related entry tags inside related/reverse related tags” would have been REALLY good information to have a few hours ago.

    As Derek Jones goes on to note in that thread, the docs really are ambiguous on this detail. They shouldn’t be. Please add a pink box to the “Relating Entries” documents page (as you already have for “Important:  For performance reasons all related entry data is cached internally…”) to shed light on this limitation.

    Regarding the limitation itself: I understand why it’s not ideal due to performance issues. But I still think it would be great to have as an option, with a large caveat in the docs.

  • #3 / Sep 17, 2007 8:11pm

    allgood2

    427 posts

    You can make a user comment to the current User Guide, and point to the identified thread, so the next person who comes along doesn’t run into the same issue before EE updates the guide. Which I assume won’t be very soon, unless there’s another release.

  • #4 / Sep 19, 2007 1:56am

    ee4me

    31 posts

    In 85 posts (err—make that 84), I will definitely consider it. For now, I’m not qualified to post.

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

ExpressionEngine News!

#eecms, #events, #releases