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.

Putting variables in links, and related_entries ignoring categories.

October 17, 2012 12:53pm

Subscribe [2]
  • #16 / Oct 29, 2012 4:38pm

    Finn

    40 posts

    I’m not 100% sure what you’re asking, but hopefully this will answer it:

    The code relates to the middle bottom page here:

    https://docs.google.com/file/d/0B1SXycn_0wClOTZuVEFXenItclE/edit

    On that page you can see that Artist 1 belongs to Exhibition 2, therefore we show his name.

    Above his name we want to show a single Work that belongs to him. But importantly that Work MUST also belong to the current Exhibition (Exhibition 2 in the example).

    In this example the Work we are showing is Work 2, because it’s the first of that Artist’s Works that belongs to Exhibition 2 (if you look at the page to the right - the detail page for this Artist in this Exhibition - you can see that the Work is called ‘Work 2’. Whereas if you look at the top middle page (a generic Artist detail page not associated with any exhibition) you can see Work 1 (purple) which we don’t want to appear on the Exhibition 2 page as it doesn’t belong to it.

    The current situation is that if I use Seg2Cat then Work 1 gets picked and displayed. Alternatively if I use the IF statement (that I tried a bit higher up the page), then again Work 1 gets picked, but this time only displayed if it is of the correct category.

    If I remove limit=“1”, then both methods work great, but unfortunately give me more Works than I would like.

  • #17 / Oct 30, 2012 12:56pm

    Kevin Smith

    4784 posts

    Yes, that was very helpful in understanding how you have this set up. Confusing at first, but now it makes sense.

    If I understand the potential solutions correctly, the downside to using the IF statement is that you would likely not see displayed the correct number of Works, correct?

    Hmm… let me think on this one for a bit here and see if I can’t come up with a solution.

  • #18 / Oct 30, 2012 1:03pm

    Finn

    40 posts

    That’s right - using the IF statement works great until I limit the results with Limit=“1”. The Seg2Cat option has almost exactly the same issue.

  • #19 / Oct 30, 2012 1:42pm

    Kevin Smith

    4784 posts

    Alright, this might be a little out-there, but I think I’ve got a solution here. Broadly speaking, it involves using an embedded template with a Channel Entries tag to accomplish this.

    Go with your IF statement method, but instead of outputting tags you’ll display, merely output the reverse related entries’ IDs in a pipe-delimited manner, making that output an embed variable. I haven’t tested this, but it should look like this:

    {embed="exhibition/artists_works" entry_list="{reverse_related_entries}{categories backspace="1"}{if category_url_title == segment_3}{entry_id}|{/if}{/categories}{/reverse_related_entries}"}

    Then in the template exhibition/artists_works, you’ll use a Channel Entries tag that specifies the entries to list and a limit to restrict the total number of entries, like so:

    {exp:channel:entries entry_id="{embed:entry_list}" limit="3"}
     <div><a href="http://{work_image}">{work_image:thumb}</a>
    
         {work_caption}</div>
    {/exp:channel:entries}

    Does that make sense? I know it’s a little awkward to wrap your mind around, but if I’ve thought through everything correctly, that should work like a charm.

  • #20 / Oct 30, 2012 1:43pm

    Kevin Smith

    4784 posts

    Note that you might also want to make exhibition/artists_works a hidden template so it can’t be accessed directly by pulling up its URI in a browser.

  • #21 / Oct 30, 2012 2:18pm

    Finn

    40 posts

    Kevin - that works perfectly! Thank you so much. I will now try and understand exactly what the code is doing - no doubt it will take me longer than the 45 minutes it took you to come up with it in the first place. Thanks to both you and Dan for not abandoning me….

  • #22 / Oct 30, 2012 3:01pm

    Kevin Smith

    4784 posts

    Great! I did some brainstorming with Dan and Shane on this one since it was definitely a unique problem you were facing. Glad to hear it worked like I expected.

    I’m going to leave this thread open for just a few more days in case anything else comes up.

  • #23 / Nov 01, 2012 11:39am

    Shane Eckert

    7174 posts

    Hey Finn,

    I wanted to check in and see how things were going.

    Please let us know if there is anything else we can do to help!

    Cheers,

  • #24 / Nov 01, 2012 12:22pm

    Finn

    40 posts

    Hi Shane,

    Everything’s working as it should, I’m pleased to say. Thanks for your help in solving my problem!

  • #25 / Nov 02, 2012 3:17pm

    Shane Eckert

    7174 posts

    Hey Finn,

    Awesome! The thanks goes to Kevin and Dan, they brainstormed this one. It was great.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases