Copied to clipboard

Flag this post as spam?

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


  • Nikolas van Etten 202 posts 162 karma points
    Jan 26, 2011 @ 23:17
    Nikolas van Etten
    0

    Best practice getting data from Multi-Node Tree Picker

    Assume I want to select e.g. 20 nodes from all-over the content tree using the Multi-Node Tree Picker or another tree picker able to save multiple values.

    What would be the best way of getting the data from these nodes? Loop through the id's from the tree picker and then use GetXmlNodeById to retrieve the data for each node? Filter $currentPage using contains? Please note that I would prefer having one nodeset to work with for further sorting, filtering etc.

    Surely the best would be to have a something like GetXmlNodesById(string[]) as an extension which would serve me all data as a complete nodeset... ;)

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 26, 2011 @ 23:38
    Chriztian Steinmeier
    1

    Hi Nikolas,

    I've been doing that on a couple of sites - basically I have a template for a single item (e.g.: match="Textpage"), and in the root ("/") template I fetch the content of the Multi Picker, tokenize the ids and apply templates to each one in succession; either via GetXmlNodeById() or if they're all below some specific node, by matching the id (e.g.: $newsRoot//Textpage[@id = current()])

    If this is too sketchy, let me know :-)

    /Chriztian

  • Nikolas van Etten 202 posts 162 karma points
    Jan 26, 2011 @ 23:45
    Nikolas van Etten
    0

    Hi Chriztian,

    I tried the following:

        <xsl:variable name="products" select="$currentPage/ancestor-or-self::*[@isDoc and @level = 1]/descendant-or-self::Product[@isDoc and contains($productIds, concat(@id, ','))]"/>

    The variable productIds is just the CSV from the tree picker. Seems fast enough for now, but I've not tested with a huge amount of nodes in the currentPage.

    Afterwards I apply a template to this nodeset matching product.

    What do you think? Any drawbacks with this approach?

     

    Nik

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 26, 2011 @ 23:54
    Chriztian Steinmeier
    0

    Hi Nik,

    Nope - been doing that too - just gotta be careful with the commas - you get a trailing "," in the $productIds property (or do you put an extra in there when fetching it?)

    I usually prepend a comma too though, to safeguard against the node with id="2345" not being matched when "12345" was actually picked...

    /Chriztian

  • Nikolas van Etten 202 posts 162 karma points
    Jan 27, 2011 @ 00:11
    Nikolas van Etten
    0

    Hi Chriztian,

    Thanks for your comments!

    Actually the productIds I tested with was created from the XML format of the tree picker so I added the comma at that point. I was also planning to edit the post and pinpoint exactly what you're writing about using a prepending comma as well since I'm aware of that easily made mistake with mismatches when you're exceeding 9999 nodes! ;)

     

    Nik

Please Sign in or register to post replies

Write your reply to:

Draft