Copied to clipboard

Flag this post as spam?

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


  • Carl 15 posts 36 karma points
    Sep 02, 2011 @ 16:53
    Carl
    0

    Media Picker for Slide Image not showing

    Hello everyone. I have a slide on the front page of a slide which rotates images by nodes selected by a macro paramter (source). Everything works fine except for the media picker.None of the images show up.I guess I made some improvements to the code and the

    "Front Page Course Slider" 

    shows on the front page but not the image.

    The media picker has a alias of:

    slideImage

    Can anyone tell me what I'm doing wrong?

     

    Thanks for your help!

     

     

     

    <?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" xmlns:CWS.Twitter="urn:CWS.Twitter" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter PS.XSLTsearch ">

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

    <xsl:param name="currentPage"/>

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

      <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <!--First slide-->
        <div>
          
          
      <xsl:if test="current()/slideImage != ''">
        <xsl:variable name="slideImage" select="umbraco.library:GetMedia(current()/slideImage, 'false')" />
        <img src="$slideImage/umbracoFile" alt="Front Page Course Slider"  />

      </xsl:if>

        
        
          
         

                      <!--image  <img src="images/slideshow.jpg" alt="" /> -->
                        <div class="caption sponsor">
                          <span class="ribbon">&nbsp;</span>
                          <h2><xsl:value-of select="@nodeName"/></h2>
                          <p><xsl:value-of select="courseAgenda" disable-output-escaping="yes"/></p>
                          <a href="{umbraco.library:NiceUrl(@id)}" class="readmore hover">read more</a>
                          <span class="shadow">&nbsp;</span>
                        </div>
        </div>
      </xsl:for-each>
                      
      
      

    </xsl:template>

    </xsl:stylesheet>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Sep 02, 2011 @ 17:27
    Tom Fulton
    0

    Hi,

    Seems like it should work.

    To troubleshoot you can add this line to dump out the contents of slideImage, so you can see if it's properly retrieving the media item and it has an umbracoFile property.  Try adding that and paste the results here

    <xsl:if test="current()/slideImage != ''">
     <xsl:variable name="slideImage" select="umbraco.library:GetMedia(current()/slideImage, 'false')" />
     <img src="$slideImage/umbracoFile" alt="Front Page Course Slider"  />
     <textarea><xsl:copy-of select="$slideImage"/></textarea>
    </xsl:if>

    -Tom

  • Carl 15 posts 36 karma points
    Sep 02, 2011 @ 17:44
    Carl
    0

    Thanks Tom. I get the following:

     

    <textarea><Image id="1172" version="2f9f93f8-f1c2-4bc6-8fbc-f7b1151b0d24" parentID="1207" level="2" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2011-08-26T14:55:30" updateDate="2011-08-26T14:55:30" nodeName="Slideshow" urlName="slideshow" writerName="" nodeTypeAlias="Image" path="-1,1207,1172"><umbracoFile>/media/499/slideshow.jpg</umbracoFile><umbracoWidth>940</umbracoWidth><umbracoHeight>300</umbracoHeight><umbracoBytes>57691</umbracoBytes><umbracoExtension>jpg</umbracoExtension></Image></textarea>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Sep 02, 2011 @ 17:53
    Tom Fulton
    0

    Sorry, I missed the problem in your first post :)

    Change the img line to:

    <imgsrc="{$slideImage/umbracoFile}"alt="Front Page Course Slider"  />

    Notice the curly braces around the $slideImage variable - to have the XSLT code get executed inside the normal HTML you'll need to wrap in these braces

    -Tom

  • Carl 15 posts 36 karma points
    Sep 02, 2011 @ 17:54
    Carl
    0

    Since my first post I changed the ID to

    slideImageID

    and used info from

    http://blog.leekelleher.com/2010/08/11/how-to-use-umbraco-library-getmedia-in-xslt-for-umbraco-v4-5/

    But still no go

    <?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" xmlns:CWS.Twitter="urn:CWS.Twitter" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter PS.XSLTsearch ">

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

    <xsl:param name="currentPage"/>

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
      


      
      
      
      
      

      <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <!--First slide-->
        <div>
          <!--Toms Code-->
            <xsl:if test="current()/slideImageID != ''">
     <xsl:variable name="slideImageID" select="umbraco.library:GetMedia(current()/slideImageID, 'false')" />
     <img src="$slideImageID/umbracoFile" alt="Front Page Course Slider"  />
     <textarea><xsl:copy-of select="$slideImageID"/></textarea>
    </xsl:if>
    <!--Toms code Ends
          
          
          
         <xsl:variable name="slideImageID" select="number($currentPage/mediaId)" />
          <!--First <xsl:variable name="slideImageID" select="number($currentPage/slideImageID)" /> -->
           <xsl:if test="$slideImageID > 0">
             <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($slideImageID, 0)" />
             <xsl:if test="$mediaNode/umbracoFile">
                 <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
             </xsl:if>
         </xsl:if>



        
        
          
         

                      <!--image  <img src="images/slideshow.jpg" alt="" /> -->
                        <div class="caption sponsor">
                          <span class="ribbon">&nbsp;</span>
                          <h2><xsl:value-of select="@nodeName"/></h2>
                          <p><xsl:value-of select="courseAgenda" disable-output-escaping="yes"/></p>
                          <a href="{umbraco.library:NiceUrl(@id)}" class="readmore hover">read more</a>
                          <span class="shadow">&nbsp;</span>
                        </div>
        </div>
      </xsl:for-each>
                      
      
      

    </xsl:template>

    </xsl:stylesheet>
  • Carl 15 posts 36 karma points
    Sep 02, 2011 @ 18:06
    Carl
    1

    Thank you Tom!!

    It Worked. I hope this code will help many others. Here is a run down on what I was trying achive incase others would like to do the same

    1. I have a javascript image slider on front page that displays a Course Title and Description.
    2. In the Document Sets I would like to be able to change the image based on the course. (Pic of classroom, etc)

    3. The macro has a source parameter which means your subnodes could be anywhere within your site

    Thanks Again

    Here is the complete code with corrections

     
    <?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" xmlns:CWS.Twitter="urn:CWS.Twitter" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter PS.XSLTsearch ">

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

    <xsl:param name="currentPage"/>

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
      


      
      
      
      
      

      <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <!--First slide-->
        <div>
          
            <xsl:if test="current()/slideImageID != ''">
     <xsl:variable name="slideImageID" select="umbraco.library:GetMedia(current()/slideImageID, 'false')" />
     <img src="{$slideImageID/umbracoFile}" alt="Front Page Course Slider"  />
     <textarea><xsl:copy-of select="$slideImageID"/></textarea>
    </xsl:if>
          
          
          
         <xsl:variable name="slideImageID" select="number($currentPage/mediaId)" />
          <!--First <xsl:variable name="slideImageID" select="number($currentPage/slideImageID)" /> -->
           <xsl:if test="$slideImageID > 0">
             <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($slideImageID, 0)" />
             <xsl:if test="$mediaNode/umbracoFile">
                 <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
             </xsl:if>
         </xsl:if>



        
        
          
         

                      <!--image  <img src="images/slideshow.jpg" alt="" /> -->
                        <div class="caption sponsor">
                          <span class="ribbon">&nbsp;</span>
                          <h2><xsl:value-of select="@nodeName"/></h2>
                          <p><xsl:value-of select="courseAgenda" disable-output-escaping="yes"/></p>
                          <a href="{umbraco.library:NiceUrl(@id)}" class="readmore hover">read more</a>
                          <span class="shadow">&nbsp;</span>
                        </div>
        </div>
      </xsl:for-each>
                      
      
      

    </xsl:template>

    </xsl:stylesheet>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Sep 02, 2011 @ 18:09
    Tom Fulton
    0

    Either of those blocks should work fine (although you need to add the curly braces in the first).

    But if you change the alias of a property on a document type (ie slideImage to slideImageID), you'll need to re-publish any documents using that property for the change to take effect in the cache.

Please Sign in or register to post replies

Write your reply to:

Draft