Copied to clipboard

Flag this post as spam?

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


  • Henrik Ladefoged 30 posts 100 karma points
    Sep 15, 2009 @ 15:57
    Henrik Ladefoged
    0

    Checking if item is empty in master template

    Version: Umbraco v 4.0.2.1

    I need to check if the editor has put any content in this field <umbraco:Item field="umbracoDidYouKnow" runat="server"></umbraco:Item> which is a simple textstring. What is the syntax for doing this?

    I am new to Umbraco and .net in general so i haven't been able to find the right syntax despite vigorous googling.

    To clarify:

    if umbracoDidYouKnow = "" then

    <div id="content">

    else

    <div id="contentWide">

    end if

  • dandrayne 1138 posts 2262 karma points
    Sep 15, 2009 @ 16:22
    dandrayne
    0

    Id use an xslt macro for this.  if the umbracoDidYouKnow is on the current page, this should work:

    <xsl:choose>
    <xsl:when test="string($currentPage/data [@alias='umbracoDidYouKnow']) != ''">
    <div id="contentWide">
    <xsl:value-of select="$currentPage/data [@alias='umbracoDidYouKnow']" />
    </div>
    </xsl:when>
    <xsl:otherwise>
    <div id="content">
    <!-- Etc -->
    </div>
    </xsl:otherwise>
    </xsl:choose>

    dsa

  • dandrayne 1138 posts 2262 karma points
    Sep 15, 2009 @ 16:23
    dandrayne
    0

    oh, should mention:  If you're brand new this may help -> http://umbraco.org/documentation/books/xslt-basics/what-is-xslt

    Post back if you continue to have difficulties, and someone should be able to help you out.

    Dan

  • Henrik Ladefoged 30 posts 100 karma points
    Sep 15, 2009 @ 17:27
    Henrik Ladefoged
    0

    Thanks for the quick replies

Please Sign in or register to post replies

Write your reply to:

Draft