Copied to clipboard

Flag this post as spam?

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


  • Tommy Messbauer 16 posts 36 karma points
    Jan 05, 2010 @ 21:50
    Tommy Messbauer
    0

    loop over items in media library, then filter by tag

    I have a list of books in a media library that I want to aggregate based on tags.  A page will have a book filter key, each book has a list of tags.  The list of books for the page will be retrieved by getting all books with a given tag.  I dont see an override for GetMedia that gets a list of all of a given type.  Does this not exists or am I not going a good job of googling?

    Thanks!

    -T

  • Laurence Gillian 600 posts 1219 karma points
    Jan 05, 2010 @ 22:08
    Laurence Gillian
    0

    As far as I am aware there is not an override.

    But you can easily filter through that data using XSLT, should be really simple.

    I'm setting up a test Umbraco install to look at another issue tomorrow, so I'll try and have a look at this as-well. 

    /Laurie

  • Tommy Messbauer 16 posts 36 karma points
    Jan 05, 2010 @ 22:35
    Tommy Messbauer
    0

    I got this working.  I can use GetMedia to get the parent folder, then loop the children.  I guess I could also start from the root and filter with the select (which would be slower because all of the nodes get touched). I was looking for a convenient function that I could just drop in and use.

    Thanks for the reply. I am all good now.

    -T

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2010 @ 23:39
    Dirk De Grave
    0

    Tommy,

    Just make sure you're aware of the performance hit when using GetMedia() recursively (2nd parameter = 'true'). It will hit the database for each media item found this way (and this may be more hits than you can imagine). Have a look at @Sebastiaan 's ( or @Cultiv 's) project which caches media items for later fast retrieval.

     

    Hope this helps.

    Regards,

    /Dirk

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 06, 2010 @ 00:20
    Chriztian Steinmeier
    1

    Just a note about that 2nd parameter, cause there's a really nasty trap there:

    You will have to supply either 0 (zero, no quotes/apostrophes) or false(), or it will actually evaluate to true when passed to C#, because 'false' is just a string in XSLT, which is will return the XSLT boolean true() when converted to a boolean value...

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft