Jump to Content
Blog Archive
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
newtelligence dasBlog 2.2.8279.16125
Email Me (Tim Gaunt)
© 2013 Tim Gaunt.
Sign In
Following on from a recent post of mine about how to setup changeable headers using the media picker in Umbraco a new site I have been working on required something a little extra -they wanted the headers to simply be chosen at random. from a given media folder.
First, create a new (blank) XSLT file and add the following:
What this does is it uses the StartNode (a media folder) passed in from the macro to loop through any valid files (in this case jpg/gif/png and pull out the image if it's valid. I was thinking about replacing the for-each loop and simply using the index but I'm not sure if there would be any performance improvement except for if there were a lot of header images in the folder.
You'll then need to create a new macro and add a parameter with the name "StartNode" and select "mediaCurrent" as the Type. That's it :)
Don't forget to follow me on Twitter.
Remember Me