Copied to clipboard

Flag this post as spam?

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


  • Vishal G.P 62 posts 122 karma points
    May 30, 2011 @ 13:22
    Vishal G.P
    0

    multi-node tree picker with unpublished items gives an error..

    Hey guys,

    i have a multi-node tree picker... It works great. 

    Now i have selected 4 items in my picker and i have an xslt that reads the selected items from the picker.. Nothing wrong here... 

    But if an editor tries to unpublish an item in the CMS which is selected in the multi-node tree picker... the page that uses this xslt breaks, because the picker doesnt know that the page is unpublished.. The question is how can i modify my xslt looping thru the items in the picker which takes into account if the page is published or not.. 

     

    thanks in advance guys.. 

     <xsl:for-each select="$currentPage/highlights//nodeId">
                <xsl:variable name="page" select="umbraco.library:GetXmlNodeById(.) " />
    <!-- am doing something here with the page variable -->
    </xsl:for-each>

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 30, 2011 @ 16:36
    Dirk De Grave
    0

    Hi Wiske80,

    Check the @id attribute after you've assigned the page variable, if it doesn't hold a value, it's not published! Or, check whether the method GetXmlNodeById returns an error xml fragment (Don't know the syntax by heard unfortunately...). Anyway, in those rare cases, I do a xsl:copy-of inside a textarea to find out what's in a variable

    <xsl:for-each select="$currentPage/highlights//nodeId">
    <xsl:variable name="page" select="umbraco.library:GetXmlNodeById(.) " /> <textarea><xsl:copy-of select="$page" /></textarea>                 <!-- am doing something here with the page variable --> </xsl:for-each>

     

    Hope this helps.

    Regards,

    /Dirk

  • Vishal G.P 62 posts 122 karma points
    May 30, 2011 @ 16:59
    Vishal G.P
    0

    Thanks alot Dirk... ur pointers helped me a lot.. Indeed there is an <error> xml tag being generated when the page is not published.. so i use that.. thanks again..

     

  • Nigel 29 posts 52 karma points
    Apr 11, 2014 @ 13:02
    Nigel
    0

    He's one I got working

           <xsl:if test="$page/@id != ''"></xsl:if>

    Arround the <li> tag fixes it

     

     

     

     

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [  <!ENTITY nbsp "&#x00A0;">]>

    <xsl:stylesheet

      version="1.0"

      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

      xmlns:msxml="urn:schemas-microsoft-com:xslt"

      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"

      exclude-result-prefixes="msxml

     umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes 

    Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings 

    Exslt.ExsltSets ">

      <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />

      <xsl:param name="currentPage"/>

      <xsl:variable name="rootPage" select="$currentPage/ancestor-or-self::root/CWS-Home/primaryNavigation"/>

      <xsl:template match="/">

        

        <!--

        uComponents: Multi-node Tree Picker - An XSLT example

        =====================================

        The Multi-node Tree Picker data-type will provide XML data based on the nodes you have selected.

        In this example, the property alias name for the Multi-node Tree Picker is "rootPage".

      -->

        

        <xsl:if test="$rootPage != ''">

          <xsl:variable name="nodeIds" select="umbraco.library:Split($rootPage,',')" />

          <xsl:variable name="currentid" select="$currentPage/@id"/>

          <ul id="primary-nav" class="nav navbar-nav">

           

            <xsl:for-each select="$nodeIds/value">

              <xsl:variable name="page" select="umbraco.library:GetXmlNodeById(current()/.)"/>

              <xsl:if test="$page/@id != ''">

                <li>

    variable name="link">

                    <xsl:value-of disable-output-escaping="yes" select="umbraco.library:NiceUrl($page/@id)" />

                  </xsl:variable>

                  <a href="{Exslt.ExsltStrings:lowercase($link)}">

                    <span select="$page/@nodeName" disable-output-escaping="yes"/>&nbsp;

                      <xsl:value-of>

                    </span>

                  </a>

                </li>

              </xsl:if>

            </xsl:for-each>

          </ul>

        </xsl:if>

      </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft