Copied to clipboard

Flag this post as spam?

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


  • pnr 131 posts 226 karma points
    Apr 01, 2009 @ 08:15
    pnr
    0

    Need help to optimize my XSLT

    I am new to XSLT and need some help to optimize my code. I need to find 2 nodes on the same level as the page I am in. those 2 nodes has a Generic property (Type) so I can tell the different between them.

    I have found a solution but I don’t think it is the best way to do it, could someone please show me some best practices?

    [code]





    Search




    Thread
    [/code]

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Apr 01, 2009 @ 10:16
    Douglas Robar
    0

    I think I'd do something like the following. (typed in the forum so there might be a small typo)

    [code]



    [/code]

    The idea here is that the select statement can find the items directly, without needing a for-each loop. Basically, each of these select statements do the same thing, which might be described in pseudo-logic as:

    Starting at the $currentPage, go up one level in the hierarchy and then look at all the nodes below that parent node (that's the "..//node" portion).

    If you're familiar with SQL, then the use of square brackets in xslt is a lot like the 'where' clause in SQL. Therefore, we are looking for all the nodes below the current page's parent "where" the level of the node is the same as the current page and the type is what we're looking for.

    Having found that node, we get it's id.

    Hope that makes sense. But remember, your solution also works and unless you've got a massive site the performance will not be significantly different because xslt is extremely fast.

    cheers,
    doug.

  • pnr 131 posts 226 karma points
    Apr 02, 2009 @ 08:25
    pnr
    0

    Thanks very much !!
    If you got the time i would like you to look on this thread http://forum.umbraco.org/yafpostst8990How-to-initialize-a-xslparam-on-behalf-of-the-querystring.aspx

    Thanks in advance!

Please Sign in or register to post replies

Write your reply to:

Draft