in one of my sites, i allow a user to specify how many of the 'latest' images in their upload folder they want to show... basically, sorting on createDate and checking position... hope this is helpful...
wow, good question... not sure how xslt handles that type of element... i would guess it keeps looping and checking... which would not be good for performance i would think...
In actual fact it isn't really a sequential loop, and that is the reason you can't have xsl:continue or xsl:break
XSLT is set based and not sequential therefore the n'th node isnt always processed before the n+1'th node; to all intent and purpose, the nodes are processed in parallel.
Sebastian's Cultiv.Media cache is a direct replacement for umbraco.library:GetMedia and will speed up accessing media files as by default they aren't cached.
[Edit] - I'm pretty sure Bob's a fan of this already but thought I'd let Eran know.
get the last 10 updated images from the media folder
hello,
i'm using this recursive macro to display my images from the media folder (that the user picked using the media picker):
the problem is that i want to display only the last 10 images that the user updated.
how can i do that?
thanks!
Eran.
in one of my sites, i allow a user to specify how many of the 'latest' images in their upload folder they want to show... basically, sorting on createDate and checking position... hope this is helpful...
<!-- start writing XSLT -->
<xsl:variable name="showLatest" select="$currentPage/data[@alias='showLatest']"/>
<xsl:if test="$currentPage/data [@alias = 'myPics'] != ''">
<div id="myPics" class="round_this">
<p class="header">my latest pics...</p>
<div id="myPicsFader">
<xsl:variable name="images" select="number($currentPage/data [@alias = 'myPics'])"/>
<xsl:if test="$images != 0">
<xsl:for-each select="umbraco.library:GetMedia($images, 'true')/node/node[@nodeTypeAlias='Image']">
<xsl:sort select="@createDate" order="descending"/>
<xsl:if test="position() <= $showLatest">
<xsl:variable name="picFile" select="./data[@alias='umbracoFile']"/>
<div class="picSlide">
<p style="text-align: center;">
<img>
<xsl:attribute name="src">/umbraco/imageGen.aspx?image=<xsl:value-of select="$picFile"/>&width=210&constrain=true</xsl:attribute>
</img>
</p>
</div>
</xsl:if>
</xsl:for-each>
</xsl:if>
</div>
</div>
</xsl:if>
thanks, thats works for me. by the way, i used updateDate instead of createDate.
by the way, i asked it before but i didnt get any answer -
when we are in the foreach loop and:
is false - it exits from the loop right away or continue to loop through all the items? (and dont enter the if statment).
if the answer is yes, do we have a way to end the foreach loop when the above if statment is false?
thanks!
Eran.
wow, good question... not sure how xslt handles that type of element... i would guess it keeps looping and checking... which would not be good for performance i would think...
thanks for the karma!
It will stay in the loop but...
In actual fact it isn't really a sequential loop, and that is the reason you can't have xsl:continue or xsl:break
XSLT is set based and not sequential therefore the n'th node isnt always processed before the n+1'th node; to all intent and purpose, the nodes are processed in parallel.
Hope that helps....
Kevin
Sebastian's Cultiv.Media cache is a direct replacement for umbraco.library:GetMedia and will speed up accessing media files as by default they aren't cached.
[Edit] - I'm pretty sure Bob's a fan of this already but thought I'd let Eran know.
thanks all about the info and dillorscroft about the Cultiv.Media tip..
is anyone experience real performence benefit after using Cultiv.Media package?
Eran.
i am a fan of the media cache :) sorry i forgot to refrence it!
is working on a reply...