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:
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.
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)
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.
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.
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 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.
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.
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!
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.
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).
<!-- The fun starts here --> <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1']"> <div class="productthumbnail">
<!-- get first product thumbnail --> <a 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.
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.
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.
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.
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 " "> ]>
<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 -->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="count(./* [@isDoc]) > 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
Hi Adam,
Is the images and nodeName displaying correctly or it is only your Count that is not working?
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.
Can you try changing the way you are concat your img to this
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 ;-)
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
Then just at your macro in your template just like you would do picking the right folder from your media
This was my intention for how it would work...
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
Hi Fuji,
My XSLT is now as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<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 -->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="count(./* [@isDoc]) > 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">
<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>
</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.
just posted my last message before seeing your latest message
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
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
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
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?
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
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
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 " "> ]>
<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 -->
<a 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]) > 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]) > 0">
<img src="{concat(substring-before(./*/umbracoFile,'.'), '_thumb.jpg')}" style="border: none;"/><br/>
</xsl:if>
with...
<a 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
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 :)
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
Adam, you're an absolute star. Thanks for that I got it working using your advice. That was a great help :)
Nice one David - glad I was able to help! I owe this forum for the help I've received from others ;-)
is working on a reply...