Copied to clipboard

Flag this post as spam?

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


  • TaoistTotty 246 posts 314 karma points
    Jul 14, 2010 @ 19:06
    TaoistTotty
    0

    Ultimate Picker CheckBoxList

    I am at the moment trying to get the selected 'names' from the items selected for each sub-page of a node.

    Using the XSLT below I am able to get the node ID but do not seem to be able to get the name (i.e. I am seeing 1124 rather than soccer).

    What I am missing and where do I need to look (I have tried GetPreValueAsString, but this is throwing and XSLT error)?

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;">
                               <!ENTITY node "*[@isDoc]">
                               <!ENTITY hidden "*[@isDoc and umbracoNaviHide = 1]">
    ]>
    <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"/>

    <xsl:param name="currentPage"/>
        <xsl:variable name="itemsPerPage" select="/macro/itemsOnPage"/>
        <xsl:variable name="numberofItems" select="count($currentPage/&node;)"/>
        <xsl:variable name="pageNumber">
          <xsl:choose>
            <xsl:when test="umbraco.library:RequestQueryString('page') = ''">
              <xsl:value-of select="1"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
    <xsl:template match="/">
          <xsl:apply-templates select="$currentPage/&node;"/>
    </xsl:template>
    <xsl:template match="&node;">
       <div class="faqcontainer">
        <a href="#" class="faqquestion">Q- <xsl:value-of select="faqQuestion"/></a>
         <span class="faqanswer"><p>A- </p><xsl:value-of select="faqAnswer" disable-output-escaping="yes"/></span>
           <div class="sportsareas">
             <ul>
               <xsl:for-each select="faqSportsCovered">
                 <li>
                   <xsl:value-of select="current()"/>
                 </li>
               </xsl:for-each>
             </ul>
           </div>
      </div>
    </xsl:template>
        <xsl:template match="&node;[&hidden;]"/>
    </xsl:stylesheet>

    Thanking you in advance.

    TT

     

  • Sascha Wolter 615 posts 1101 karma points
    Jul 14, 2010 @ 19:30
    Sascha Wolter
    0

    As far as I know the Ultimate Picker just stores the node IDs of the selected values, e.g. if you have chosen 3 items in a checkbox list they will get stored as

    '1133,4210,2874'.

    In order to get e.g. the node names of these you would have to first get the node for each id and then read out their values, e.g.

    <xsl:for-each select="Exslt.ExsltString:tokenize(faqSportsCovered, ',')">

    <xsl:value-of select="umbraco.library:GetXmlNodeById(current())/@nodeName" />

    </xsl:for-each>

    Cheers,

    Sascha

  • TaoistTotty 246 posts 314 karma points
    Jul 14, 2010 @ 20:30
    TaoistTotty
    0

    Hi Sascha

    Thanks for the suggestion.

     Have just tried this, but am seeing the following error:

    Error occured

    Error in XSLT at line 38, char 12
    36: <div class="sportsareas">
    37: <ul>
    38: >>> <xsl:for-each select="Exslt.ExsltString:tokenize(faqSportsCovered, ',')"> <<<
    39: <li>
    40: <xsl:value-of select="umbraco.library:GetXmlNodeById(current())/@nodeName"/>

    I should have mentioned that I am using version 4.5.

    Regards

    TT

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 14, 2010 @ 21:01
    Lee Kelleher
    1

    Hey TT,

    I wrote a blog post a while back about how to use XSLT with the Ultimate Picker data-type...

    http://blog.leekelleher.com/2009/09/08/umbraco-ultimate-picker-xslt-example/

    You could use the Exslt tokenize() function, but I prefer the umbraco.library:Split() method. Here's an example of the XSLT:

    <xsl:variable name="preNodes">
        <xsl:for-each select="umbraco.library:Split(faqSportsCovered, ',')/value">
            <xsl:copy-of select="umbraco.library:GetXmlNodeById(.)"/>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="nodes" select="msxml:node-set($preNodes)/&node;" />
    <xsl:if test="$nodes">
        <div class="sportsareas">
            <ul>
                <xsl:for-each select="$nodes">
                    <li>
                        <xsl:value-of select="@nodeName"/>
                    </li>
                </xsl:for-each>
            </ul>
        </div>
    </xsl:if>
    

    Cheers, Lee

  • TaoistTotty 246 posts 314 karma points
    Jul 14, 2010 @ 21:10
    TaoistTotty
    0

    Hi Lee

    Thanks very much this worked like a dream.

    I will now read your blog article to see why and how.

    It would be a help to me, and I am sure others, if there could be an area on the forum giving other blogs etc. to look at.

    Once again thanks Lee.

    Regards

    TT

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 14, 2010 @ 21:13
    Lee Kelleher
    0

    Hi TT,  I should really copy across my blog posts to the wiki section ... I'll get around to it one day!

    For now, remember that Google is your friend. Obviously you need the right keywords. ;-)

    e.g. http://www.google.co.uk/search?q=Ultimate+Picker+XSLT

    Glad it worked out!

    Cheers, Lee.

  • TaoistTotty 246 posts 314 karma points
    Jul 14, 2010 @ 21:37
    TaoistTotty
    0

    Hi Lee

    Getting the Google search terms that work and be fun sometimes.

    I had no luck this time.

    Thanks once again.

    TT

Please Sign in or register to post replies

Write your reply to:

Draft