Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Sep 14, 2011 @ 15:15
    Lee
    0

    More Efficient Way Of Doing This

    I need to find the start node of my forum, I have no idea where in the tree it could be and users can move it - But I need to get hold it.  Currently I'm doing this...

    var forumRoot = Node.GetNodeByXpath("//Forum");

    But I know the dreaded double slash isn't very efficient on large sites! Looking at you XSLT nutters lovely people to help me with some tips ;)

    Thanks in advance

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 14, 2011 @ 15:32
    Jeroen Breuer
    0

    I don't know of a better way, but maybe this topic can help you: http://our.umbraco.org/forum/developers/api-questions/18933-Query-multiple-websites. It shows a lot of ways how you can query the Umbraco xml structure. Maybe you find something useful.

    Jeroen

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Sep 14, 2011 @ 15:35
    Hendy Racher
    2

    Hi Lee,

    Since you know you want to return the first match, I wonder if the following would help (I'd be interested to know) ?

    var forumRoot =Node.GetNodeByXpath("//Forum[1]");

    Alternativily (if it really is slow) how about caching the result in application scope with an event hander such that if the Forum node moves to wipe the app scope ?

    HTH,

    Hendy

  • Lee 1130 posts 3088 karma points
    Sep 14, 2011 @ 15:37
    Lee
    0

    @Jeroen - Thanks for the link

    @Hendy - Thanks, I have added that - I am in fact caching the query once I have it, was just looking for the best way any time it has to make a call to that method :)

  • PBrack 20 posts 42 karma points
    Sep 14, 2011 @ 15:55
    PBrack
    0

    How about using an event handler to detect a move and updating your cached location?

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Sep 14, 2011 @ 15:58
    Peter Duncanson
    0

    Like the idea of storing its position for speed.

    The [1] should speed it up as the parser should stop once its got a match rather than getting all Forums and then pruning off the first one.

    Might be better still to just go from the root /root/descendant::Forum[1] at least that would start from the top of the tree (the forum should not be too deep right?). Not sure if it would help much but I'd be interested to see what it does for performance?

    Pete

  • David Verberckmoes 46 posts 77 karma points
    Sep 16, 2011 @ 11:45
    David Verberckmoes
    1

    Lee,

    what about setting a property on the root node that refers to the Forum node? This way the forum can be moved around.

    Another way is to get it by the nodeTypeAlias although I'm not sure this is the fastest way.

    Rgds,

    David

Please Sign in or register to post replies

Write your reply to:

Draft