Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Maton 387 posts 660 karma points
    Nov 12, 2009 @ 17:41
    Tom Maton
    0

    Count number of media items with specific extension

    Hi All,

    This probably such a simple thing to do but I can't for the life of me work out how to do it

    So far I have:

    <xsl:value-of select="count(umbraco.library:GetMedia(2115,'true')/node [string(data [@alias = 'umbracoExtension']) = 'pdf'])"/>

    But I keep on getting 0 when there are about 150 in there and its beginning to drive me mad!!

    Any help much appreciated

    Tom

  • Finn 86 posts 50 karma points
    Nov 12, 2009 @ 18:29
    Finn
    0

    Hi Tom

    What about changing the 'true' to a simple 1 as in

    <xsl:value-of select="count(umbraco.library:GetMedia(2115,1)/node [string(data [@alias = 'umbracoExtension']) = 'pdf'])"/>

    or you can try this approach:

    <xsl:variable name="images" select="umbraco.library:GetMedia(2115, 1)" />
    <xsl:variable name="numberOfImages" select="count($images/node)" />

    Hope it helps

    /Finn

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 12, 2009 @ 21:40
    Dirk De Grave
    0

    Be aware of the performance penalty if you have a large number of media items!

    Also, not sure whether GetMedia() returns a flat structure of nodes. If not, one may switch to //node instead of /node in the count() method.

     

    Hope this helps.

    Regards,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft