Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Mar 23, 2012 @ 19:25
    Amir Khan
    0

    MultiNode tree picker and images

    Hi,


    I have this code to pull some text/ images from a multi node tree picker, I'm perplexed as to why its not returning images?

    Any help would be greatly appreciated!

    <?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" />

      <xsl:param name="currentPage"/>
        
        <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 "treePicker".
      -->

      <!-- First we check that the Multi-node Tree Picker has any nodeId values -->
      <xsl:if test="$currentPage/featuredProjects/MultiNodePicker/nodeId">
          <ul id="featuredHome" class="equalHeight">
            <!-- Loop through each of the nodeId values -->
            <xsl:for-each select="$currentPage/featuredProjects/MultiNodePicker/nodeId">
              <!--
     Since we only have the nodeId value, we need to get the actual content 
    node using umbraco.library's GetXmlNodeById method -->
              <!--
     If you prefer to use pure XPath, then used this: 
    "$currentPage/ancestor-or-self::*[@isDoc and @level = 
    1]/descendant-or-self::*[@isDoc and @id = current()]" -->
              <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" />
              <li>
                <!-- Output the URL using umbraco.library's NiceUrl method -->
                <!-- Image -->
                
                
                <xsl:variable name="mediaId" select="number(thumbnailImage)" />
                <xsl:if test="$mediaId > 0">
                  <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(., 0)" />
                  <xsl:if test="$mediaNode/umbracoFile">
                    <a href="{umbraco.library:NiceUrl(@id)}"><img src="{$mediaNode/umbracoFile}" alt="{$mediaNode/@nodeName}"  /></a>
                  </xsl:if>
                </xsl:if>
                <!-- Image -->
                 <h3><xsl:value-of select="$node/@nodeName" /></h3>     
                 <p><a href="{umbraco.library:NiceUrl(.)}"><xsl:value-of select="$node/projectAbstract"/><span>+</span></a></p>
              </li>
            </xsl:for-each>
          </ul>
      </xsl:if>

    </xsl:template>

    </xsl:stylesheet>
  • Amir Khan 1287 posts 2744 karma points
    Mar 23, 2012 @ 19:38
    Amir Khan
    0

    Got it!

     

    <!-- image -->
    <xsl:variable name="mediaId" select="number($node/articleThumbnailImage)" />
                          <xsl:if test="$mediaId > 0">
                            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
                            <xsl:if test="$mediaNode/umbracoFile">
                              <img class="thumbnail" src="{$mediaNode/umbracoFile}" alt="{$mediaNode/@nodeName}" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" />
                            </xsl:if>
                          </xsl:if>
    <!-- image -->
Please Sign in or register to post replies

Write your reply to:

Draft