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.

Relationship field

January 10, 2010 9:21pm

Subscribe [3]
  • #1 / Jan 10, 2010 9:21pm

    honey4d

    15 posts

    Hello. I have created two weblogs (‘region’ & ‘areas’). ‘areas’ contains a custom relationship field (dropdown) called ‘region-link’ which allows me to link each area to a region. I would like to display a list of all the ‘areas’ that are not linked to a ‘region’.

    I have tried several things and thought the following would work…

    {exp:weblog:entries weblog="areas"}
    {if region-link == ''}
    {title}
    {/if}
    {/exp:weblog:entries}

    ...but it doesn’t. Any suggestions as to what I am doing wrong would be appreciated.

    Jon

  • #2 / Jan 11, 2010 3:51am

    John Henry Donovan

    12339 posts

    Jon,

    Try evaluating against a value of 0 instead

    {exp:weblog:entries weblog="areas"}
    {if region-link == '0'}
    {title}
    {/if}
    {/exp:weblog:entries}
  • #3 / Jan 11, 2010 10:13am

    honey4d

    15 posts

    Thanks John.

    I’m afraid that didn’t work either.

    The following display’s all the ‘areas’ linked to regions.

    {exp:weblog:entries weblog="areas"}
    {if region-link != ''}
    {title}
    {/if}
    {/exp:weblog:entries}

    The only thing I can do is create an ‘unallocated’ region and link them to that.

    Unless anyone has any other suggestions.

    Jon

  • #4 / Jan 11, 2010 8:29pm

    Adam Dorsey

    1439 posts

    Since that is a related field, would it help to do something like this:

    {exp:weblog:entries weblog="areas"}
    {related_entries id="region-link"}
    {if no_related_entries}
    {title}
    {/if}
    {/related_entries}
    {/exp:weblog:entries}

    It depends how you are using the field though.

    -Adam

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

ExpressionEngine News!

#eecms, #events, #releases