1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 How do I "return" code?

Discussion in 'XenForo Questions and Support' started by SBMinerYT, Aug 19, 2015.

  1. SBMinerYT

    SBMinerYT Member

    Basically, I'm trying to stop the code from going any further in an if statement.

    Stopping the if statement with </xen:if> doesn't seem to work.

    I put an if statement inside of an if statement, and if that second if statement that is inside the main if statement is true, I want the code to stop after the <span> tags.

    Any way to do this?
     
  2. SBMinerYT

    SBMinerYT Member

    @Chris D, apologies for the tag, but I did research this and got no help from Google.

    I'm sort of in a rush to gather this information if you don't mind giving me a hand.
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    I'm going to need a more detailed example, I'm not sure I fully follow what you're trying to do.
     
  4. SBMinerYT

    SBMinerYT Member

    @Chris D

    Here is my code:
    Code:
    <xen:if is="{$forum.lastPost.date}">
                        <xen:if is="in_array({$forum.node_id}, array(10, 11, 12))">
                        <span class=noMessages muted">Latest message hidden.</span>
                        RETURN
                    <span class="lastThreadTitle"><span>{xen:phrase latest}:</span> <a href="{xen:link posts, $forum.lastPost}" title="{$forum.lastPost.title}">{$forum.lastPost.title}</a></span>
                    <span class="lastThreadMeta">
                        <span class="lastThreadUser"><xen:if is="{xen:helper isIgnored, $forum.last_post_user_id}">{xen:phrase ignored_member}<xen:else /><xen:username user="$forum.lastPost" /></xen:if>,</span>
                        <xen:datetime time="$forum.lastPost.date" class="muted lastThreadDate" data-latest="{xen:phrase latest}: " />
                    </span>
                <xen:else />
                    <span class="noMessages muted">({xen:phrase contains_no_messages})</span>
                </xen:if>
    If the second if statement (<xen:if is="in_array({$forum.node_id}, array(10, 11, 12))">) is TRUE, I want to stop the code after the <span> right below it, so it doesn't display the "latest" message in the node layout.

    If it's not true, and it's not one of those specified node ID's, then it'll continue with the code. What exactly would I put to replace that "RETURN" line I have there as a place holder?
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    If I've understood correctly then I think you want something like this:

    Code:
    <xen:if is="{$forum.lastPost.date}">
        <xen:if is="in_array({$forum.node_id}, array(10, 11, 12))">
            <span class=noMessages muted">Latest message hidden.</span>
        <xen:else />
            <span class="lastThreadTitle"><span>{xen:phrase latest}:</span> <a href="{xen:link posts, $forum.lastPost}" title="{$forum.lastPost.title}">{$forum.lastPost.title}</a></span>
                <span class="lastThreadMeta">
                    <span class="lastThreadUser"><xen:if is="{xen:helper isIgnored, $forum.last_post_user_id}">{xen:phrase ignored_member}<xen:else /><xen:username user="$forum.lastPost" /></xen:if>,</span>
                    <xen:datetime time="$forum.lastPost.date" class="muted lastThreadDate" data-latest="{xen:phrase latest}: " />
                </span>
        </xen:if>
    <xen:else />
            <span class="noMessages muted">({xen:phrase contains_no_messages})</span>
    </xen:if>
     
  6. SBMinerYT

    SBMinerYT Member

    Works perfect!

    Thanks very much Chris.
     

Share This Page