Copied to clipboard

Flag this post as spam?

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


  • neil 5 posts 20 karma points
    Feb 10, 2009 @ 18:08
    neil
    0

    How to list all Media Pickers in $currentPage

    Hi,

    How do I loop through all Media Pickers in $currentPage?

    I have tried and failed (all day) to loop through each node and if it's a media picker to output the url.

    Can somebody point me in the right direction please?

    I thought this might work? but no. You can see I am struggling.
    [code]

    [/code]

    Many Thanks,

    Neil

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 10, 2009 @ 19:46
    Dirk De Grave
    0

    Hi,

    Hope this is not a typo (Mind the /node I've added on the for-each loop):

    [code][/code]

    Regards,
    /Dirk

  • neil 5 posts 20 karma points
    Feb 11, 2009 @ 11:58
    neil
    0

    Thanks again for your help Dirk.

    I am sure your code is correct, but it doesn't work for me.

    I probably don't understand my location in the xml properly.
    I have modified BoostTextPage to include ten media pickers.
    In an instance of a content page (Contact Us) I have assigned values to the first 3 media Pickers.

    If I go to my xslt file and load a media picker like this I can access the named picker ok:
    [code][/code]

    but repeating my code to get a named mediaPicker and display it ten times looked really clumsy so I thought a loop seemed logical - but it's proving much harder than I expected.

    If I do this I get zero
    [code][/code]

    aha! [slaps forehead]
    The macro containing the xslt file is actually in BoostMaster not BoostTextPage. I bet I have to move up the tree to get the media pickers?

    I'll keep on with it.
    Phew, there is quite a steep learning curve for this. Great product though.

    Thanks again for your help

    Neil


  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 11, 2009 @ 12:22
    Dirk De Grave
    0

    Hi neil,

    Also misread the post... all mediapickers belong to the same page, so iterating the child nodes of the currentPage won't work... my bad!

    If you have created 10 media pickers on a page, they should all be available as:

    $currentPage/data[@alias='rotatorImage1']
    $currentPage/data[@alias='rotatorImage2']
    ...
    $currentPage/data[@alias='rotatorImage10']

    For each of those, check whether string(..) != '' and if so, grab the media file associated with the id.
    A loop could do fine, but you'd need to find a way to construct 'rotatorImageX' as the identifier. Concat() will help, but I'm not sure on how to set the index? Maybe some other may have an answer to this.

    Hope this helps.

    Regards,
    /Dirk

  • neil 5 posts 20 karma points
    Feb 11, 2009 @ 12:27
    neil
    0

    Now I know the loop is genuinely tricky I can justifiably take the easy route and write out code for each named picker. I just wanted to check I wasn't missing a trick.

    x1000 Thanks,
    Neil

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 11, 2009 @ 13:00
    Dirk De Grave
    0

    Hi,

    Got intrigues by your question, so I decided to give it a google-go and found an interesting snippet at http://snippets.dzone.com/tag/loop which I've changed to:
    [code]






    [/code]

    Other may have other solutions, I'd be glad to hear about it...

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft