Copied to clipboard

Flag this post as spam?

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


  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 11:35
    Adam
    0

    Need Help with List Page As Thumbnails - Thumbnails not showing

    Hi All,

    I'm trying to display thumbnails for child product pages on a product category page. I set up an XSLT file using the appropriate template.

    I modified the code to use my thumbnail alias 'pageThumbnailImage' that I setup in the product document type where I select the image I want to upload as the thumbnail. Below is the modified line of code:

    <img src="{concat(substring-before(./*/pageThumbnailImage,'.'), '_thumb.jpg')}" width="90" height="90" alt="{@nodeName}" style="border: none;"/><br/>

    Here is my complete XSLT:

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

    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
    <div class="photo">

    <!-- get first photo thumbnail -->
        <href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="count(./* [@isDoc]) &gt; 0">
    <img src="{concat(substring-before(./*/pageThumbnailImage,'.'), '_thumb.jpg')}" width="90" height="90" alt="{@nodeName}" style="border: none;"/><br/>
    </xsl:if>
          <b><xsl:value-of select="@nodeName"/></b><br/>
        </a>
          <xsl:value-of select="count(./* [@isDoc])"/> Photo(s)
    </div>
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

    The category page displays the product nodeName and '0 Photo(s)' underneath - no thumbnails. What am I doing wrong? Am I missing something really obvious? I've only just started using Umbraco and XSLT so it's probably a rookie mistake.

    I read some threads that looked related but I haven't made any progress.

    All help appreciated!

    Adam

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 05, 2011 @ 11:46
    Fuji Kusaka
    0

    Hi Adam,

    Is the images and nodeName displaying correctly or it is only your Count that is not working?

     

  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 12:03
    Adam
    0

    Thanks for replying Fuji. The nodename is displaying but the thumbnail is not. I think the count is okay but I don't know. You can see the page at http://jjachinasupplies.com.webserver2.ukdnp.com/products-supplied/automotive-products/motorcycles.aspx (wasn't sure if it was okay to post a link so I unlinked it).

    I'm using Umbraco 4.7.1. 

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 05, 2011 @ 12:05
    Fuji Kusaka
    0

    Can you try changing the way you are concat your img to this

    <img src="{concat(substring-before(umbraco.library:GetMedia(pageThumbnailImage, 'true'),'.'),'_Thumbnail.jpg')}" />
  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 12:25
    Adam
    0

    Thanks Fuji. Tried your code and got the following error when saving:

    System.OverflowException: Value was either too large or too small for an Int32. 
    at System.Convert.ToInt32(Double value) 
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) 
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) 
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) 
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) 
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    I have no idea what this means ;-)

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 05, 2011 @ 12:45
    Fuji Kusaka
    0

    Adam tell me are you pulling your images from your media Section right?

    I think you try doing something like when creating your XSLT go to its related Macro and add the Alias (slide), Name (media) and Tyepe (MediaCurrent) in your parameter tab.

    In your XSLT you can add this 

     

    <xsl:variable name="media" select="/macro/slide"/>
    <xsl:template match="/">
         <xsl:if test="$media">         
         <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($media/*/@id, 'true')" />
              <xsl:for-each select="$mediaItems/Image">            
    <a href="{umbracoFile}"> 
                  <img src="{concat(substring-before(umbracoFile,'.'),'_thumb.jpg')}" width="90" height="90" alt="{@nodeName}" style="border: none;" />  <br/>   
                     </a>
               </xsl:for-each>
          </xsl:if>  
    </xsl:template>

    Then just at your macro in your template just like you would do picking the right folder from your media

  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 13:28
    Adam
    0

    This was my intention for how it would work...

    1. I create a product page and I choose an image from my computer as the pageThumbnailImage and it gets uploaded (I assume it gets uploaded to the /Media/ folder). I repeat this for all products in a category.
    2. I then create a category page and I insert the ListPagesAsThumbnails macro into the richtext editor for the page content I have setup in the Document Types.
    I will try your method and see how that goes.
  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 05, 2011 @ 13:56
    Fuji Kusaka
    0

    Adam,

    If you are to choose this method i posted ealier you will need to upload your images by creating them directly in the media section. 

    //fuji

  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 14:11
    Adam
    0

    Hi Fuji,

    My XSLT is now as follows:

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

    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
    <div class="photo">

    <!-- get first photo thumbnail -->
        <href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="count(./* [@isDoc]) &gt; 0">
    <img src="{concat(substring-before(./*/pageThumbnailImage,'.'), '_thumb.jpg')}" width="90" height="90" alt="{@nodeName}" style="border: none;"/><br/>
    </xsl:if>
          <b><xsl:value-of select="@nodeName"/></b><br/>
        </a>
          <xsl:value-of select="count(./* [@isDoc])"/> Photo(s)
    </div>
    </xsl:for-each>

    </xsl:template>

    <xsl:variable name="media" select="/macro/slide"/>
    <xsl:template match="/">
         <xsl:if test="$media">         
         <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($media/*/@id, 'true')" />
              <xsl:for-each select="$mediaItems/Image">            
    <href="{umbracoFile}"
                  <img src="{concat(substring-before(umbracoFile,'.'),'_thumb.jpg')}" width="90" height="90" alt="{@nodeName}" style="border: none;" />  <br/>   
                     </a>
               </xsl:for-each>
           </xsl:if>  
    </xsl:template>    
        
    </xsl:stylesheet>

    Did I add your code correctly?

    I added the parameter ('show' checkbox is selected, 'Alias' is 'slide', 'Name' is 'media' and 'Type' is 'mediaCurrrent'). I went to add the macro into a page using the insert macro in the Rich Text editor as I am adding these here, not in a template. I came across a problem - when I was asked to select the media I could only choose the /Media/ folder. There are no sub folders in the /Media/ folder to select. If I go to the 'Media' section in the Umbraco admin it is empty but if I check via FTP the folder has a number of subfolders with the images in.

     

  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 14:12
    Adam
    0

    just posted my last message before seeing your latest message

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 05, 2011 @ 14:16
    Fuji Kusaka
    0

    No worries, remember to Create a new Folder in the media section under which you will upload your images. Then you can pick your media folder by using your macro.

    //fuji

  • Adam 51 posts 81 karma points
    Oct 05, 2011 @ 14:31
    Adam
    0

    Ok Fuji,

    Made a little progress. Please check http://jjachinasupplies.com.webserver2.ukdnp.com/products-supplied/automotive-products/motorcycles.aspx and you can see some thumbnails visible - yay! 

    I manually added a folder and subfolders and images as follows:

    Media
    --Product Item Thumbnails
    ----Motorcycles
    ------Tricycles
    --------passenger-001 (this is a jpg product thumbnail image)

    --------passenger-001 (this is a jpg product thumbnail image)

    Is this format correct for organising the thumbnails in the /Media/ folder? 

    Now I need to get the thumbnails pointing to the correct child product pages and also have the child product nodeNames displaying and linking. I think my latest code above is wrong - I think I probably pasted your code incorrectly.

    I understand that the XSLT is displaying the thumbnails within the folder I choose when inserting the Macro but how does the XSLT know in which order to display them and which product a thumbnail should link to?

    Thanks for your help so far Fuji - much appreciated!

    Adam

  • Adam 51 posts 81 karma points
    Oct 06, 2011 @ 10:24
    Adam
    0

    Been playing around some more and not gotten anywhere. I still don't understand how the List Sub Pages As Thumbnails XSLT template is supposed to work. With the original Umbraco template, can someone explain how and where it gets the thumbnail image from?

    Other templates have a comment stating either that you need to modify the level setting for example or create a parameter in the macro but the List Sub Pages As Thumbnails template doesn't give me any pointers so I'm lost.

    Am I supposed to add a document type property so the user adds a thumbnail for each product page? I just don't see how the XSLT chooses the thumbnail image for each sub page.

    Can anyone explain? Maybe simple comments on the template code would help - sorry for my lack of knowledge.

    Thanks,
    Adam

  • David Johnson 12 posts 32 karma points
    Oct 19, 2011 @ 18:10
    David Johnson
    0

    I'm struggling with this exact problem as well.

    I'm quite new to umbraco though. Trying to figure things out myself but not having much luck.

    Can anyone help?

  • Rich Green 2246 posts 4008 karma points
    Oct 19, 2011 @ 18:36
    Rich Green
    0

    Hey,

    Having looked at 'ListSubPagesAsThumbnails' I have no idea how it's supposed to work.

    I would have a look at this post instead

    http://our.umbraco.org/wiki/reference/code-snippets/listfilesfrommediafolderxslt/listing-files-from-a-media-folder-in-umbraco-45x-with-xslt

    Cheers

    Rich

  • Adam 51 posts 81 karma points
    Oct 19, 2011 @ 19:25
    Adam
    0

    Hi David,

    I actually got it working just a few hours ago. I'd given up on the code earlier in this discussion and started from scratch using the List Sub Pages As Thumbnails template modified using the GetMedia code. Take a look at http://www.jjachinasupplies.com/products-supplied/automotive-products/motorcycles.aspx to see it in action and if it is something like you are looking for. Let me know and I'll post the exact XSLT I'm using here when I get back to my other computer (don't have my admin login info right now to check for you - sorry).

    Adam

  • Adam 51 posts 81 karma points
    Oct 19, 2011 @ 21:36
    Adam
    0

    Hi again David. For the site above I used the following XSLT code:

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

    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1']">
    <div class="productthumbnail">

    <!-- get first product thumbnail -->
        <href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="pageThumbnailImage2 != ''">
       <img src="{umbraco.library:GetMedia(pageThumbnailImage2,'false')/umbracoFile}" alt="{@nodeName}" width="150" height="97" /><br/>
    </xsl:if>

    <!-- 
    <xsl:if test="count(./* [@isDoc]) &gt; 0">
    <img src="{concat(substring-before(./*/umbracoFile,'.'), '_thumb.jpg')}" style="border: none;"/>
    </xsl:if>
    -->

          <b><xsl:value-of select="@nodeName"/></b><br/>
        </a>
      <xsl:value-of select="pageThumbnailDescription"/>
    </div>
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

    So the main modification of the original Umbraco template simply involved replacing...

    <xsl:if test="count(./* [@isDoc]) &gt; 0">
    <img src="{concat(substring-before(./*/umbracoFile,'.'), '_thumb.jpg')}" style="border: none;"/><br/>
    </xsl:if>

    with...

    <href="{umbraco.library:NiceUrl(@id)}">
    <xsl:if test="pageThumbnailImage2 != ''">
       <img src="{umbraco.library:GetMedia(pageThumbnailImage2,'false')/umbracoFile}" alt="{@nodeName}" width="150" height="97" /><br/>
    </xsl:if>

    Note that pageThumbnailImage2 is the alias for the thumbnail image for each sub page. I added the property pageThumbnailImage2 to my document type and set it as a 'Media Picker'. I then added a few test images to the Media section so that when I create a product page I can choose an image (from the Media section) for the product thumbnail.

    I also replaced...

    <xsl:value-of select="count(./* [@isDoc])"/> Photo(s)

    with..

    <xsl:value-of select="pageThumbnailDescription"/>

    This includes another alias I setup in the document type to display a short description instead of the number of photos. 

    TIP: I downloaded the Desktop Media Uploaded so that when I create my thumbs I can quickly upload them to the Media folder instead of doing each upload individually from within Umbraco. Looks like that tool will save a lot of hassle and clicks.

    I hope the above helps! Let me know.

    Adam

  • David Johnson 12 posts 32 karma points
    Oct 20, 2011 @ 01:01
    David Johnson
    0

    Thanks so much Rich and Adam for the quick responses. Everyone seems really helpful here.

    Can't wait to look at this tomorrow when I get into work. Hopefully I can use your advice well. Looking forward to getting this to work and also understanding it a little better. One step at a time.

     

    Dave :)

  • Adam 51 posts 81 karma points
    Oct 20, 2011 @ 11:37
    Adam
    0

    No problem David. I'm brand new to Umbraco too nd I certainly don't have a coder's brain so this forum is an excellent resource and people here are a huge help. Let us know if you get it all working. Good luck!

    Going to mark my post with the code above as the thread solution.

    Adam

     

  • David Johnson 12 posts 32 karma points
    Oct 20, 2011 @ 11:40
    David Johnson
    0

    Adam, you're an absolute star. Thanks for that I got it working using your advice. That was a great help :)

  • Adam 51 posts 81 karma points
    Oct 20, 2011 @ 11:42
    Adam
    0

    Nice one David - glad I was able to help! I owe this forum for the help I've received from others ;-)

Please Sign in or register to post replies

Write your reply to:

Draft