Copied to clipboard

Flag this post as spam?

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


  • Wade 43 posts 159 karma points
    Aug 23, 2014 @ 06:36
    Wade
    0

    Display image from defined node using content picker

    Hi All, I'm having a problem displaying content from nodes defined in a content picker.

    The content picker chooses a page to link to on the site. On each page there is a an 'upload image' property called pageLinkImage. Each page will have an image assigned to it so that when I want create a link to any page around the site, I don't have to manually upload an image each time.

    I have managed to get the link name to display, but I am having trouble getting the image to appear.

        <?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:Examine="urn:Examine" 
        exclude-result-prefixes="msxml umbraco.library Examine ">
    
    
      <xsl:output method="xml" omit-xml-declaration="yes" />
    
      <xsl:param name="currentPage"/>
    
      <!-- Input the related links property alias here -->
    
    
    
      <xsl:template match="/">
    
        <!-- The fun starts here -->
    <div class="col-xs-6">
        <xsl:if test="number($currentPage/pageLink1) > 0">  
    
    
                    <a href="{umbraco.library:NiceUrl($currentPage/pageLink1)}">
    
                        <img class="img-responsive" src="{umbraco.library:GetXmlNodeById($currentPage/pageLink1)/data [@alias = 'pageLinkImage']/umbracoFile}"/>
    
                    </a>
    
    
          <a class="textlink" href="{umbraco.library:NiceUrl($currentPage/pageLink1)}">
              <h4><xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/pageLink1)/@nodeName"/> ›</h4>
          </a>
        </xsl:if>
    </div>
    
      </xsl:template>
    
    </xsl:stylesheet>
    

    The piece of code that isn't working is this line:

    <img class="img-responsive" src="{umbraco.library:GetXmlNodeById($currentPage/pageLink1)/data [@alias = 'pageLinkImage']/umbracoFile}"/>
    

    Any help would be appreciated,

    Cheers,

    Wade.

  • Wade 43 posts 159 karma points
    Aug 25, 2014 @ 11:46
    Wade
    100

    Ok, I just figured it out myself, so in case anyone is looking to do the same thing... I changed the problem line to this:

    <img class="img-responsive" src="{umbraco.library:GetXmlNodeById($currentPage/pageLink1)/pageLinkImage}"/>
    

    Which gives the final code of this:

        <?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:Examine="urn:Examine" 
        exclude-result-prefixes="msxml umbraco.library Examine ">
    
    
      <xsl:output method="xml" omit-xml-declaration="yes" />
    
      <xsl:param name="currentPage"/>
    
      <!-- Input the related links property alias here -->
    
    
    
      <xsl:template match="/">
    
        <!-- The fun starts here -->
    <div class="col-xs-6">
        <xsl:if test="number($currentPage/pageLink1) > 0">  
    
    
                    <a href="{umbraco.library:NiceUrl($currentPage/pageLink1)}">
                        <img class="img-responsive" src="{umbraco.library:GetXmlNodeById($currentPage/pageLink1)/pageLinkImage}"/>
                    </a>
    
          <a class="textlink" href="{umbraco.library:NiceUrl($currentPage/pageLink1)}">
              <h4><xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/pageLink1)/@nodeName"/> ›</h4>
          </a>
        </xsl:if>
    </div>
    
      </xsl:template>
    
    </xsl:stylesheet>
    
Please Sign in or register to post replies

Write your reply to:

Draft