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.

{if} statments in side {related_entries}

November 18, 2011 6:01am

Subscribe [3]
  • #1 / Nov 18, 2011 6:01am

    stevealfa

    11 posts

    EE2

    I’m looking to be able to have a list of subjects that can have more than one related ‘tutor’
    but tutors may or may not have an “open” status.
    If a tutor does I’d like to have a link to their page and if not (“moderation” status) then still show their name but not a link to their page
    I currently have this:

    <div class="sub-tutor">
    {related_entries id="sub_tutor_1"}
    <h2>{if status="Open"}<a href="http://{path=tutors/about/{url_title}}">{/if}{tut_first_name} {tut_last_name}{if status="Open"}</a>{/if}</h2>
    <p>{/related_entries}</div><!-- /.sub-tutor --><br />
    <div class="sub-tutor"><br />
    {related_entries id="sub_tutor_2"}</p><h2>{if status="Open"}<a href="http://{path=tutors/about/{url_title}}">{/if}{tut_first_name} {tut_last_name}{if status="Open"}</a>{/if}</h2>
    <p>{/related_entries}</div><!-- /.sub-tutor -->

    but adding the if statements stops the page from showing is there another way around this using the related field?

    This doesn’t seem to work either:

    <div class="sub-tutor">
    {related_entries id="sub_tutor_1" status="Open"}
    <h2><a href="http://{path=tutors/about/{url_title}}">{tut_first_name} {tut_last_name}</a></h2>
    <p>{/related_entries}</div><!-- /.sub-tutor -->

    but all is fine when I remove the ‘status’

    Thanks.

  • #2 / Nov 20, 2011 9:30am

    Sean C. Smith

    3818 posts

    Hi stevealfa,

    In your first code sample could you change {if status="Open"} to {if status=="open"} notice the extra “=” and the lowercase “o”

    Sean

  • #3 / Nov 21, 2011 5:51am

    stevealfa

    11 posts

    Thanks Sean it was my syntax (the ‘==’ bit) the case of the letters didn’t seem to matter though, strangely.

  • #4 / Nov 22, 2011 12:28pm

    Kyle Cotter

    730 posts

    Hey Steve,

    Glad the syntax change was able to help you out here.

    Is there anything else we can help you with?

    Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases