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.

Comparing URL Segments and Relationship field values

December 18, 2009 3:34am

Subscribe [1]
  • #1 / Dec 18, 2009 3:34am

    HVAP

    3 posts

    I have two weblogs. Albums and Songs.

    I have a relationship field in the Songs weblog that associates songs with albums.

    I have a template “playlist” in template group “music”.

    When linking to this template, I pass the url_title of the album as the third segment /music/playlist/album-name

    I would then like to compare this segment, with the url_title from the related entries of each song to determine whether or not to show them.

    I’m hoping I haven’t architected this entire setup incorrectly.

    Any advice on how I can practically accomplish the equivalent of:

    {if segment_3=={related_entries id="song_album"}{url_title}{/related_entries}}

    Any thoughts are appreciated.

    Incidentally, just printing out the related_entries tag works fine, I’m presuming the if statement just doesn’t like a tag pair nested in there… tried assigning the value to a variable and comparing that without luck as well.

  • #2 / Dec 18, 2009 3:49am

    HVAP

    3 posts

    I’m surprised this works… I really thought I might have hit a dead end here, but I’ve got it working with the following:

    {related_entries id="song_album"}
        {if segment_3==url_title}
    {/related_entries}
  • #3 / Dec 18, 2009 11:57am

    Ingmar

    29245 posts

    Yes that should work. So, you’re all set for now? Just making sure.

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

ExpressionEngine News!

#eecms, #events, #releases