Given the following code Im using for a photo gallery, when I try to use my $folder variable instead of the folder number '1329' then I get the XSLT error below. I have very little experience with XSLT so if anyone can point me in the right direction it will be greatly appreciated.
'System.OverflowException: Value was either too large or too small for an Int32.'
The following code above will not even return the id of the media folder. Am I missing something vital here? I have a parameter on my PhotoGallery macro called 'Folder' with an alias of 'folder' and a type of 'mediaCurrent'.
What structure do you wish to see sorry Im not sure?
My basic problem is that I wish to have a number of photo galleries. Each using the same XSLT file to display the gallery so I can have a photo gallery on a page that maps to a folder in the Media area. I can get the images to come through when I hard code a folder id but I need the folder id to be dynamic in the PhotoGalleryXSLT or otherwise I would have to have an XSLT file for each gallery, as each gallery would need to refer to a different folder from the Media area.
The gallery folders are as follows in the Media area.
Surely this must have been done before?? :-S
The issue is getting the ID of the folder chosen when you use mediaCurrent as a parameter on the macro?
At the risk of tearing my hair out I have now assigned a mediaPicker property to a new Photo Gallery document type that I have created. I choose the medai folder for the photo gallery when I create a page using this new document type.
I can now see the correct folder id rendered to the browser in a text area as suggested by Kim. It reads 1329.
I have removed the folder parameter from the XSLT.
Happy Days you would think.....however Im still getting the error 'System.OverflowException: Value was either too large or too small for an Int32.' when I try to use the $folder variable instead of a hard coded 1329 in the following code.
Any further help greatly appreciated before I go the the mental asylum.
*Rob - On a further point, there have been numerous times including this post on the Our Umbraco forum when I have edited or added a substantial post only for it to be completely lost upon save / submission so I know what you mean, really needs to be sorted out by the Umbraco powers that be!
Sorry, just to double check an obvious gotcha - are you getting the overflow exception just when you save the macro, or when you actually use the macro?
Rob, I didnt even think to check, but it does actually work from the front side when you check the 'Skip Testing' checkbox in the editor when saving the XSLT file. Strange that it will not pass testing in the XSLT parser though.
I guess we can consider this sorted as a result of everyones contributions (with the exception of the XSLT parser error) as I now have the functionality that I required. I ll mark as solved the one which I feel helped the most which was the suggestion to use a document type with properties as opposed to parameters.
The reason it doesn't work when you save is that the $currentPage variable is empty, so your document property is empty - all the library functions that expect an ID will return this overflow error on save if you use anything based on the $currentPage (or querystring, or anything that results in an empty string if there is no context). I normally use the Visualize XSLT option and select a node for testing.
I do like the save to be able to use the testing though and not throw errors, so what I normally do is something like:
Then just use $mediaID in the library call. Your macro will work propery everywhere there is a currentPage, and will use 1 on save, which although it won't match an actual item, won't throw an exception.
Kicking myself really, this is such a common issue I could have saved you loads of time, but I misread your original post and thought it was not working in your actual page, sorry!
I've always used document properties myself - the mediaCurrent macro parameter type is so unintuitive!
XSLT Variable for folder number
Given the following code Im using for a photo gallery, when I try to use my $folder variable instead of the folder number '1329' then I get the XSLT error below. I have very little experience with XSLT so if anyone can point me in the right direction it will be greatly appreciated.
'System.OverflowException: Value was either too large or too small for an Int32.'
<?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" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch "> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:variable name="folder" select="/macro/folder"/> <xsl:template match="/"> <!-- start writing XSLT --> <xsl:for-each select="umbraco.library:GetMedia(1329, 1)/Image"> <li> <a class="image" rel="lightbox"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:GetMedia(@id, 0)/umbracoFile"/> </xsl:attribute> <img> <xsl:attribute name="src"> <xsl:value-of select="umbraco.library:Replace(umbraco.library:GetMedia(@id, 0)/umbracoFile, '.', '_thumb.')"/> </xsl:attribute> </img> </a> </li> </xsl:for-each> </xsl:template> </xsl:stylesheet>
you're selecting folder, shouldn't you be select /@id on it aswell?
as it seems now i think you're putting the whole xml of folder in the variable..
Thanks for the reply kows.
Do you mean when I am selecting the variable ie
Hi Kevin
Could you try putting an xsl:if around the for-each? Something like this:
<xsl:if test="$folder != ''">
<xsl:for-each select="umbraco.library:GetMedia($folder, 1)/Image">
<li>
<a class="image" rel="lightbox">
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:GetMedia(@id, 0)/umbracoFile"/>
</xsl:attribute>
<img>
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:Replace(umbraco.library:GetMedia(@id, 0)/umbracoFile, '.', '_thumb.')"/>
</xsl:attribute>
</img>
</a>
</li>
</xsl:for-each>
</xsl:if>
/Kim A
The following code above will not even return the id of the media folder. Am I missing something vital here? I have a parameter on my PhotoGallery macro called 'Folder' with an alias of 'folder' and a type of 'mediaCurrent'.
Any help greatly appreciated.
what is your structure actually looking like?
you're trying to select a property of a macro by xslt?
dont think that's even possible oO
What structure do you wish to see sorry Im not sure?
My basic problem is that I wish to have a number of photo galleries. Each using the same XSLT file to display the gallery so I can have a photo gallery on a page that maps to a folder in the Media area. I can get the images to come through when I hard code a folder id but I need the folder id to be dynamic in the PhotoGalleryXSLT or otherwise I would have to have an XSLT file for each gallery, as each gallery would need to refer to a different folder from the Media area.
The gallery folders are as follows in the Media area.
Surely this must have been done before?? :-S
The issue is getting the ID of the folder chosen when you use mediaCurrent as a parameter on the macro?
Thanks again for everyones help.
ive been searching some in projects here and learned some stuff,
i'm mostly the programmer not the xslt guy.
maybe this can help:
http://maanehunden.wordpress.com/2010/07/07/how-to-make-a-xslt-macro-that-can-be-used-inside-an-umbraco-richtext-editor/
edit: this is how i would do it
http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/list-images-from-mediafolder-in-umbraco-45-plus
Have you added the folder parameter into the actual Macro definition?
Go to: Umbraco -> Developer -> Macros -> [Your Macro] :: Parameters
The parameters are not picked up automatically from the XSLT, and you can't use them until they are added in manually.
Oh for God's sake, why doesn't the bloody edit work? Sorry, I had a scroll / brain malfunction and missed your last post. Will have a read through.
Hi again Kevin
Could you try the code I provided, and then change your variable to this:
I can't remember what the mediaCurrent returns, so could you try printing it out in a textarea like this:
/Kim A
At the risk of tearing my hair out I have now assigned a mediaPicker property to a new Photo Gallery document type that I have created. I choose the medai folder for the photo gallery when I create a page using this new document type.
I can now see the correct folder id rendered to the browser in a text area as suggested by Kim. It reads 1329.
I have removed the folder parameter from the XSLT.
Happy Days you would think.....however Im still getting the error 'System.OverflowException: Value was either too large or too small for an Int32.' when I try to use the $folder variable instead of a hard coded 1329 in the following code.
Any further help greatly appreciated before I go the the mental asylum.
*Rob - On a further point, there have been numerous times including this post on the Our Umbraco forum when I have edited or added a substantial post only for it to be completely lost upon save / submission so I know what you mean, really needs to be sorted out by the Umbraco powers that be!
Cheers
would be handier if you post your final (error)code. Confuses me :p
Did you try $mediaFolderId/node/@id ?
Sorry, just to double check an obvious gotcha - are you getting the overflow exception just when you save the macro, or when you actually use the macro?
Rob, I didnt even think to check, but it does actually work from the front side when you check the 'Skip Testing' checkbox in the editor when saving the XSLT file. Strange that it will not pass testing in the XSLT parser though.
I guess we can consider this sorted as a result of everyones contributions (with the exception of the XSLT parser error) as I now have the functionality that I required. I ll mark as solved the one which I feel helped the most which was the suggestion to use a document type with properties as opposed to parameters.
Many thanks to everyone for their assistance.
Cheers
Kevin
The reason it doesn't work when you save is that the $currentPage variable is empty, so your document property is empty - all the library functions that expect an ID will return this overflow error on save if you use anything based on the $currentPage (or querystring, or anything that results in an empty string if there is no context). I normally use the Visualize XSLT option and select a node for testing.
I do like the save to be able to use the testing though and not throw errors, so what I normally do is something like:
Then just use $mediaID in the library call. Your macro will work propery everywhere there is a currentPage, and will use 1 on save, which although it won't match an actual item, won't throw an exception.
Kicking myself really, this is such a common issue I could have saved you loads of time, but I misread your original post and thought it was not working in your actual page, sorry!
I've always used document properties myself - the mediaCurrent macro parameter type is so unintuitive!
is working on a reply...