New 4.5 schema - using umbraco.library:GetMedia for a slideshow
Greetings all,
I'm having trouble with understanding the new schema for 4.5. I'd like to write an xslt script that does the following:
Document Type: Slideshow
Document Type: Slideshow Item (child document type of Slideshow). This document type has a field "slideshowItem" which is of type MediaPicker.
There will be several Slideshow Items which are child documents of Slideshow, each with its own media image. I'd like the xslt to traverse through every child item of Slideshow and output the image in the Slideshow item using umbraco.library:GetMedia. Can someone please suggest some ways to do this? I had this working in the 4.0 schema but I just don't understand the 4.5 schema well enough.
Also if you have suggestions on how to debug xslt scripts, that would be very helpful. Basically when I write a script wrong, I get nothing output which makes it difficult to trouble-shoot what I did wrong.
I'm also relatively new to umbraco environment, but therefore I would like to try to help you,
My guess would be that you could print all the children out from under the document type slideshow so.
<xsl:for-each select="./child::*[@isDoc and self::slideshow]"> <li> <xsl:if test="$currentPage/your Media picker alias !=''"> <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/your Media picker alias , 0)" /> <xsl:variable name="alt" select="umbraco.library:GetMedia($currentPage/your Media picker alias , 0)/@nodeName" /> <img src="{$media/umbracoFile}" alt="{$alt}"/> </xsl:if> </li> </xsl:for-each>
But as I said, I am fairly new, so if I am wrong, I hope you can bear with me.
The way I used to
debug my scripts by typing my variables out to see if they get the
right value, or use the visualization button in Umbraco, to see if I get
hold of the right data when I think I've written the right script
Here is the (simplified) code I had working under 4.0.x. I am running 4.5.2 at this time. Thanks a lot for your responses, and please let me know if this sample code changes how you would suggest coding the solution. I'm also still wondering what your approach is for debugging these xslt scripts!
When I tried code similar to your translated snippet, I get an xslt save error "System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)". My code looks like:
For some reason, the following very simple xslt doesn't display any results (meaning no nodes are matched). I've set up the document types as I noted in the first post in this thread, and I have some content published (one node of type slideshow and two child nodes under that of type slideshowItem). I've modeled this code after the example at http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema. Does anyone know what is happening?
Are your Document Types named "slideshow" and "slideshowItem" ?
The way you describe it in the first post, I'd assume your doctypes were named "Slideshow" and "Slideshow_Item" (based on the names you gave) - and then the property on Slideshow_Item documents would have the name "slideshowItem" - is that correct?
XML (and thus XSLT) is case-sensitive so it's important to get these right - my first code example uses "SlideShow" instead of "Slideshow" so that wouldn't work - have you tried that piece of code with your exact names?
New 4.5 schema - using umbraco.library:GetMedia for a slideshow
Greetings all,
I'm having trouble with understanding the new schema for 4.5. I'd like to write an xslt script that does the following:
Document Type: Slideshow
Document Type: Slideshow Item (child document type of Slideshow). This document type has a field "slideshowItem" which is of type MediaPicker.
There will be several Slideshow Items which are child documents of Slideshow, each with its own media image. I'd like the xslt to traverse through every child item of Slideshow and output the image in the Slideshow item using umbraco.library:GetMedia. Can someone please suggest some ways to do this? I had this working in the 4.0 schema but I just don't understand the 4.5 schema well enough.
Also if you have suggestions on how to debug xslt scripts, that would be very helpful. Basically when I write a script wrong, I get nothing output which makes it difficult to trouble-shoot what I did wrong.
Thanks a lot,
-NorthK
Hi North
Could you provide us with the xslt that you had working with the old XML schema in v4.0. Then we can rewrite that code.
And another small question - Are you running v4.5 or v4.5.1/4.5.2? I ask because there's a small change in the XML in v4.5 and v4.5.X :)
/Kim A
Hello NorthK,
I'm also relatively new to umbraco environment, but therefore I would like to try to help you,
My guess would be that you could print all the children out from under the document type slideshow so.
But as I said, I am fairly new, so if I am wrong, I hope you can bear with me.
The way I used to debug my scripts by typing my variables out to see if they get the right value, or use the visualization button in Umbraco, to see if I get hold of the right data when I think I've written the right script
Hope it can help you.
/ Dennis
Hi NorthK,
This is my take, using the match templates approach (change Document Type names if necessary):
/Chriztian
All,
Here is the (simplified) code I had working under 4.0.x. I am running 4.5.2 at this time. Thanks a lot for your responses, and please let me know if this sample code changes how you would suggest coding the solution. I'm also still wondering what your approach is for debugging these xslt scripts!
Thanks again,
-NorthK
The translation of that snippet would be:
For debugging I use the XMLDump (duh - wrote it for that :-) package, or the "debug textarea copy-of trick":
/Chriztian
Chriztian,
When I tried code similar to your translated snippet, I get an xslt save error "System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)". My code looks like:
Any ideas? Thanks a lot,
-NorthK
North,
could you try making a check to see if the current node contains an image like this:
/Kim A
Hello again all,
For some reason, the following very simple xslt doesn't display any results (meaning no nodes are matched). I've set up the document types as I noted in the first post in this thread, and I have some content published (one node of type slideshow and two child nodes under that of type slideshowItem). I've modeled this code after the example at http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema. Does anyone know what is happening?
Thanks,
-NorthK
Hi NorthK,
Are your Document Types named "slideshow" and "slideshowItem" ?
The way you describe it in the first post, I'd assume your doctypes were named "Slideshow" and "Slideshow_Item" (based on the names you gave) - and then the property on Slideshow_Item documents would have the name "slideshowItem" - is that correct?
XML (and thus XSLT) is case-sensitive so it's important to get these right - my first code example uses "SlideShow" instead of "Slideshow" so that wouldn't work - have you tried that piece of code with your exact names?
Otherwise, try the textarea-debug method:
- and post some of it here so we can see the exact setup
/Chriztian
is working on a reply...