Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mitra 81 posts 196 karma points
    Nov 20, 2013 @ 12:46
    Mitra
    0

    When Macro (xslt file) returns null

    Hello, 

    How can i say that if the macro returns nothing show a message. for example if there is no event write there are no events.

    is there anything to set for this like how we put useIfEmpty for items?

    Thanks,

    Mitra

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Nov 20, 2013 @ 13:43
    Dennis Aaen
    0

    Hi Mitra,

    Since I don´t know your XSLT could I will try to help you with some psdo code.

    You could make an choose statement in your XSLT file.

    If your events are children of your currentpage you could count on them to see if there are any.

    You can have so many when tests that you needs <xsl:when test="></xsl:when> but only one otherwise.

    <xsl:choose> 
    <xsl:when test="count($currentPage/Events) > 0">
      <!-- Do your code for events -->
    </xsl:when>
    <xsl:otherwise>
      No events
    </xsl:otherwise>
    </xsl:choose>

    If you are working on multilingual sites, you could use a dictionary item for the No events text, by using the Umbraco library extension GetDictionaryItem()

    <xsl:value-ofselect="umbraco.library:GetDictionaryItem('YourDictionaryItemsName')"/>

    I hope something like this can help you get what you are after.

    /Dennis

  • Mitra 81 posts 196 karma points
    Nov 20, 2013 @ 14:39
    Mitra
    0

    i can't use this, because i have got another check in my loop that if the event is checked for being visible then show it. this check will show there is event eventhough the even it not visible.

     

    I wanted to put a flag but again the variable's value cannot be changes.

    <xsl:for-each select="$eventItems">

    <xsl:sort select="uNewsDate" order="descending"/> 

    <xsl:if test="position() &lt;= $MaxItems">

    <xsl:variable name="Visible" select="eventVisible" />

    <xsl:if test="$Visible = '1'" >

    <ul>

    ....

    </ul>

    </xsl:if>

    </xsl:if>

    </xsl:for-each> 

     

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Nov 20, 2013 @ 14:58
    Dennis Aaen
    100

    Hi Mitra,

    Maybe you could try something like that.            

    <xsl:for-each select="$eventItems">
        <xsl:sort select="uNewsDate" order="descending"/>
            <xsl:if test="position() &lt;= $MaxItems">
           
            <xsl:variable name="Visible" select="eventVisible" />
           
            <xsl:choose>
                <xsl:when test="count($Visible = '1')> 0">
                    <ul>
                        ....
                    </ul>
                </xsl:when>
                <xsl:otherwise>
                    No events
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:for-each>

    Maybe you don´t need the count.

    /Dennis

  • Mitra 81 posts 196 karma points
    Nov 28, 2013 @ 14:55
    Mitra
    0

    Sorry Dennis, I just realised that i didn't thank you for your reply. 

    It was a great trick which i didn't know.

    Thanks a lot again 

    Mitra

     

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Nov 28, 2013 @ 20:42
    Dennis Aaen
    0

    That's okay Mitra.

    So you did managed to resolve your case with the code I provide to you?

    /Dennis

  • Mitra 81 posts 196 karma points
    Nov 29, 2013 @ 10:48
    Mitra
    0

    Yes, it worked. thanks again - I'm just about posting another question :P

     

Please Sign in or register to post replies

Write your reply to:

Draft