I have some subfolders in Media, and would like to display thumbnails for them regardless of which folder they are in. This is what I cooked up, but it isn't returning results as I desire. Generally I am getting "Error parsing XSLT file: \xslt\Page_RelatedMediaThumbs.xslt"...
<!--MACRO PARAMS: PageNode The Page for which the links data should be returned (you can leave blank if using currentpage) contenttree DataToReturn What is the RelatedMedia Property? propertyTypePicker UseCurrentPage Use the current page rather than a specified page bool ImageWidth Width of Thumbnails (pixels) (you only need to specify width OR height) number ImageHeight Height of Thumbnails (pixels) (you only need to specify width OR height) number ShowCaption Display the caption? bool NumToShow How many images should be displayed (leave blank for all) number -->
To be honest, I didn't digest your xslt looking for errors. Before that I wanted to ask if the xslt error is when you save the macro or when you run it?
If on save... click the 'skip testing' box. Does the macro run properly? GetMedia() is notorious for blowing up on the initial xslt save but generally runs fine.
If when running... what are the next couple lines of the error? Usually there will be a clue about line number, syntax expected, or something like that to help narrow down where it blew up. Don't forget that you might get more output if you use the ?umbDebugShowTrace=true querystring.
Does the macro run sometimes and not others? If so, any chance the filename of the folder or image that blows up is the problem? I recall there was a bug in GetMedia for some characters in the filenames. Perhaps that's related?
Two things what I can see at the first view. First a samll suggestion to use "xsl:choose" instead of two or three "xsl:if". So you can achieve an "if else" solution.
The second thing is that you are using the getMedia with recursive = false. Why? Don't you want to iterate through the medias? with recursive = true you get all medias starting with the media id in one structure which you can iterate through. Am I wrong with my purpose? Also use xsl:copy-of to get the xml out of the current node to debug.
@Doug: It saves just fine, When I place the macro in a template and run the page, I get the error instead of the output. I have tried "?umbDebugShowTrace=true" - but when I scroll down, I never see any obvious error (no red message). I have noticed that If I comment out the call to IterateMedia in the check for the Folder, it will render the thumbnails for media not in a folder.
@Thomas: I will try to clean up the ifs... I tried with various true/false options on GetMedia, it didn't make any difference in the output. At this point, I was just trying to get each media item individually, via an integer MediaID value, and process them independently of one another... Am I misunderstanding how GetMedia() operates?
Additional info: I'm not sure if this has anything to do with it, but the media to process is coming from a property on the page - "TestimonialRelatedPortfolioMEDIA", which uses a custom datatype based on TreeMultiPicker (http://treemultipicker.codeplex.com/)
I tested GetMedia with the true paremeter and it worked fine. Please try it and output it via xsl:copy-of instead of xsl:value-of then take a look into the html source. There you can see the complete xml which is returned where you then can iterate through.
To your additional info. The node structure for medias are only given for the medias put in via the backend which you can see in the media section. Medias inserted on a content page via UploadField aren't stored in a hierarchy: they are flat.
The media items are stored in the Media Section - they are associated with a content node via the TreeMultiPicker-based property (similar to MultipleMediaPicker). The issue is that the TreeMultiPicker allows you to select individual media files (aka an image) and also allows you to select a media folder - which is handy, so you could add media to a media folder without having to update the content node with the additional items. But for display purposes, I have the ID of the folder, and I want to return all the images inside the media folder.
It is possible I screwed up the GetMedi(x, true) at some point...
It occured to me that I might want to approach the entire problem from a different angle. If I could just "search" and compile a list of all the applicable media items, then I would be able to loop through them easier, and only output a certain number of them, if desired. To do this, I took a look at Doug's XSLTSearch files, and have managed to grab out little bits for my own purposes. My challenge is getting the syntax correct... Perhpas you can help me...
I have verified that $yetPossibleNodes does contain media nodes, and $searchTerm is returning a single Media Node Id... so supposedly, that MediaNodeId should be located in the path of some media nodes... but I am getting an empty list returned. Am I not formatting the "contains" statement correctly?
I think my other issue will have to do with getting items regardles so far down the folder hierarchy they are... I can't seem to access them all "flat", without somehow traversing the hierarchy.
I have no problem iterating through the media nodes cause they are similiar to the normal nodes. let me show you an example, perhaps it will get clearer.
On my blog I have a media hierachy you can see in this picture.
To get the medias from blog.thoehler.com I used the following xslt:
The results are shown on the website like in this picture.
But if you rightclick and go to the html code you get an xml structure like this. So you can see that youhave an xml hierarchy which is the same like for content nodes. So now you can iterate through the items.
Thanks, Thomas, with your examples I was able to get it to return correctly, and then with more research and work than it should have taken ;-) I managed to get it to display only the desired number of images (as passed in via the macro)
So, what this does now, is it will take a content node and a propertyname (of a property which retuns a list of media nodes) and will create thumbnails of the number of items specified - regardless of how many levels "deep" it has to go to get the images. Phew!
<!--MACRO PARAMS: PageNode The Page for which the links data should be returned (you can leave blank if using currentpage) contenttree DataToReturn What is the RelatedMedia Property? propertyTypePicker UseCurrentPage Use the current page rather than a specified page bool ImageWidth Width of Thumbnails (pixels) (you only need to specify width OR height) number ImageHeight Height of Thumbnails (pixels) (you only need to specify width OR height) number ShowCaption Display the caption? bool NumToShow How many images should be displayed (leave blank for all) number -->
Iterate Media Folders?
Hello,
I have some subfolders in Media, and would like to display thumbnails for them regardless of which folder they are in. This is what I cooked up, but it isn't returning results as I desire. Generally I am getting "Error parsing XSLT file: \xslt\Page_RelatedMediaThumbs.xslt"...
Any ideas about where I am going wrong?
Thanks!
Heather
Hi, Heather,
To be honest, I didn't digest your xslt looking for errors. Before that I wanted to ask if the xslt error is when you save the macro or when you run it?
If on save... click the 'skip testing' box. Does the macro run properly? GetMedia() is notorious for blowing up on the initial xslt save but generally runs fine.
If when running... what are the next couple lines of the error? Usually there will be a clue about line number, syntax expected, or something like that to help narrow down where it blew up. Don't forget that you might get more output if you use the ?umbDebugShowTrace=true querystring.
Does the macro run sometimes and not others? If so, any chance the filename of the folder or image that blows up is the problem? I recall there was a bug in GetMedia for some characters in the filenames. Perhaps that's related?
cheers,
doug.
Two things what I can see at the first view. First a samll suggestion to use "xsl:choose" instead of two or three "xsl:if". So you can achieve an "if else" solution.
The second thing is that you are using the getMedia with recursive = false. Why? Don't you want to iterate through the medias? with recursive = true you get all medias starting with the media id in one structure which you can iterate through. Am I wrong with my purpose? Also use xsl:copy-of to get the xml out of the current node to debug.
hth, Thomas
Thanks for your replies!
@Doug: It saves just fine, When I place the macro in a template and run the page, I get the error instead of the output. I have tried "?umbDebugShowTrace=true" - but when I scroll down, I never see any obvious error (no red message). I have noticed that If I comment out the call to IterateMedia in the check for the Folder, it will render the thumbnails for media not in a folder.
@Thomas: I will try to clean up the ifs... I tried with various true/false options on GetMedia, it didn't make any difference in the output. At this point, I was just trying to get each media item individually, via an integer MediaID value, and process them independently of one another... Am I misunderstanding how GetMedia() operates?
Additional info:
I'm not sure if this has anything to do with it, but the media to process is coming from a property on the page - "TestimonialRelatedPortfolioMEDIA", which uses a custom datatype based on TreeMultiPicker (http://treemultipicker.codeplex.com/)
~Heather
Hi Heather,
I tested GetMedia with the true paremeter and it worked fine. Please try it and output it via xsl:copy-of instead of xsl:value-of then take a look into the html source. There you can see the complete xml which is returned where you then can iterate through.
To your additional info. The node structure for medias are only given for the medias put in via the backend which you can see in the media section. Medias inserted on a content page via UploadField aren't stored in a hierarchy: they are flat.
hth, Thomas
Thanks, Thomas, for your feedback.
The media items are stored in the Media Section - they are associated with a content node via the TreeMultiPicker-based property (similar to MultipleMediaPicker). The issue is that the TreeMultiPicker allows you to select individual media files (aka an image) and also allows you to select a media folder - which is handy, so you could add media to a media folder without having to update the content node with the additional items. But for display purposes, I have the ID of the folder, and I want to return all the images inside the media folder.
It is possible I screwed up the GetMedi(x, true) at some point...
It occured to me that I might want to approach the entire problem from a different angle. If I could just "search" and compile a list of all the applicable media items, then I would be able to loop through them easier, and only output a certain number of them, if desired. To do this, I took a look at Doug's XSLTSearch files, and have managed to grab out little bits for my own purposes. My challenge is getting the syntax correct... Perhpas you can help me...
This is what I am trying to use:
I have verified that $yetPossibleNodes does contain media nodes, and $searchTerm is returning a single Media Node Id... so supposedly, that MediaNodeId should be located in the path of some media nodes... but I am getting an empty list returned. Am I not formatting the "contains" statement correctly?
Thanks!
Heather
I think my other issue will have to do with getting items regardles so far down the folder hierarchy they are... I can't seem to access them all "flat", without somehow traversing the hierarchy.
Hi Heather,
I have no problem iterating through the media nodes cause they are similiar to the normal nodes. let me show you an example, perhaps it will get clearer.
On my blog I have a media hierachy you can see in this picture.
To get the medias from blog.thoehler.com I used the following xslt:
The results are shown on the website like in this picture.
But if you rightclick and go to the html code you get an xml structure like this. So you can see that youhave an xml hierarchy which is the same like for content nodes. So now you can iterate through the items.
The following xslt
gives the output you can see at http://blog.thoehler.com/test
So if you only want to get the images in one list you can do something like
I hope I could help you with this epic post ;-)
Thomas
Thanks, Thomas, with your examples I was able to get it to return correctly, and then with more research and work than it should have taken ;-) I managed to get it to display only the desired number of images (as passed in via the macro)
So, what this does now, is it will take a content node and a propertyname (of a property which retuns a list of media nodes) and will create thumbnails of the number of items specified - regardless of how many levels "deep" it has to go to get the images. Phew!
I hope this code can help someone else who is attempting the same insanity!
~Heather
is working on a reply...