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.

related_entries and selecting which blog to pull {title} from

September 09, 2010 6:17pm

Subscribe [3]
  • #1 / Sep 09, 2010 6:17pm

    mikec964

    18 posts

    I’m putting events (from an event blog) on a calendar. Some of the events are actually workshops, and they have a link to a workshop blog with the description, pre-requisites, and so forth.

    If the event has a link to a workshop, I’d like to use the event title as a heading. If the event is linked to a workshop, then I’d like to use the workshop’s title.

    The code I’ve written works for workshop links, but when there’s no link, it just shows ‘{title}’.

    Here’s my code:

    {exp:weblog:entries weblog="events" }
        {!-- If this entry is linked to a workshop, then use the workshop title, description, and body instead of the event fields. --}
        <h1>
            {related_entries id="event_workshop_link"}
                {if no_related_entries}
                    {title}
                {/if}
                {title}
            {/related_entries}
  • #2 / Sep 10, 2010 4:33am

    John Henry Donovan

    12339 posts

    mikec964,

    Yes tags aren’t going to parse within that conditional. Try the following method though and let us know if that works for you

    {exp:weblog:entries weblog="events" }
        {!-- If this entry is linked to a workshop, then use the workshop title, description, and body instead of the event fields. --}
        <h1>
    {if event_workshop_link =='0'}
    {title}
    {if:else}
            {related_entries id="event_workshop_link"}
                {title}
            {/related_entries}
    {/if}
    {/exp:weblog:entries}
  • #3 / Sep 10, 2010 1:20pm

    mikec964

    18 posts

    That works!

    I don’t have enough cred to post this as a comment on the docs page, but your reply taught me two things that might be useful to the next person:

    1) You can use {if the_relation_field =='0'} to test to see if the_relation_field is populated

    2) No tags are parsed inside the {if no_related_entries} conditional

    Thanks again!

  • #4 / Sep 10, 2010 5:14pm

    Sue Crocker

    26054 posts

    Glad John was able to help. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases