Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 16, 2011 @ 21:19
    Fuji Kusaka
    0

    Checking published node

    Hi i have an issue here where i need to check if nodes under a folder with id 1315 are published. What am trying to do is if the nodes are published i will get the values and if not a message will be displayed instead.

    So far he nodes are displayed when i publish them but when unpublish  i cant get the message "No Page found" to display. I also have a max number 3 items being published.

    here is how i proceeded.

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1315)/* [@isDoc and string(umbracoNaviHide) != '1']">
        <xsl:sort select="current()/newsPublished" order="descending"/>
          <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(1315)" />
                 
         
      <xsl:choose>
        <xsl:when test="$node/@nodeName !='' and position() &lt;=  $maxNews">
            <href="{umbraco.library:NiceUrl(@id)}">                                     
                 <xsl:value-of select="shortDescription" disable-output-escaping="yes"/> 
            </a>                              
          
        </xsl:when>    
       
          <xsl:otherwise>
            No Page Found
        </xsl:otherwise>
      </xsl:choose>
      </xsl:for-each>
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 16, 2011 @ 21:33
    Chriztian Steinmeier
    1

    Hi Fuji,

    Unpublished nodes does not exist in the XML, so you can't really test their (non-)existence.

    If you need to do something like that, you'll have to "unpublish" by means of a property instead (but that defeats the purpose, I think).

    /Chriztian

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 16, 2011 @ 21:39
    Fuji Kusaka
    0

    Hi Chriztian,

    Thanks for replying. I somehow got it working by using some css hacks. So that when there is no value being displayed and image instead takes over. 

    But what if i want to add the image in my xslt instead...

     <xsl:choose>
        <xsl:when test="position() &lt;=  $maxNews">
            <a href="{umbraco.library:NiceUrl(@id)}">                                     
                 <xsl:value-of select="shortDescription" disable-output-escaping="yes"/> 
            </a>                              
          
        </xsl:when>    
       
          <xsl:otherwise>
            <img src="myimg.gif"/ >
        </xsl:otherwise>
      </xsl:choose>

     
    Here again i cant get <xsl:otherwise> to take over when the nodes are unpublished. 
     
    //fuji

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 16, 2011 @ 22:13
    Chriztian Steinmeier
    0

    Hi Fuji,

    I really don't think I understand - are you trying to add the image in case there's only e.g. 2 published nodes, so you can always have $maxNews items showing?

    /Chriztian

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 16, 2011 @ 22:15
    Fuji Kusaka
    0

    Nope am trying to show the image when no nodes are published.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 16, 2011 @ 22:38
    Chriztian Steinmeier
    0

    Hi Fuji,

    OK - well, then try this:

    <xsl:variable name="newsRoot" select="umbraco.library:GetXmlNodeById(1315)" />
    <xsl:variable name="newsPages" select="$newsRoot/*[@isDoc][not(umbracoNaviHide = 1)]" />
    
    <xsl:for-each select="$newsPages">
        <xsl:sort select="newsPublished" order="descending" />
        <xsl:if test="position() &lt; $maxNews">
            <a href="{umbraco.library:NiceUrl(@id)}">                                     
                <xsl:value-of select="shortDescription" disable-output-escaping="yes"/> 
            </a>                                      
        </xsl:if>
    </xsl:for-each>
    <xsl:if test="not($newsPages)">
        <p>No pages found</p>
    </xsl:if>

    /Chriztian

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 16, 2011 @ 23:09
    Fuji Kusaka
    0

    Yes, this works perfectly Chriztian.

    Regards

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft