Copied to clipboard

Flag this post as spam?

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


  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 10:57
    Martin
    0

    how to retrieve specific node by nodeName?

    Hi there..
    I'm new to Umbraco, but I've worked with XSLT and another similair CMS.

    I need to develop a top menu (I'm currently using the latest release of Umbraco 4).

    so far I have a sitemap-structure like this.

    [code]
    +Content
    +RootOfWebsite (redirects to Home)
    +Home
    +page1
    +page2
    +page3
    +Something2
    +page1
    +page2
    +page3
    +Something3
    +Something4
    +Something5
    [/code]


    While the top menu needs to work on all the pages regardless of where you are in the node-tree, I need to create a parameter or variable selecting the TopLevel node (in this case RootOfWeb).

    Usually I would do this with the following expression (or something simmiliar):



    if I try to return the value of "$root" , nothing happens....

    I've also tried replacing current() with $currentPage , but that doesn't help me either ....

    also, I do not understand why a simple command like:
    doesn't return anything ... I can only get the $currentPage id by adding $currentPage to the select-statement (ie. ="$currentPage/@id" )... and if I add current() instead, nothing happens either ... no return-value ... no error ... just no ouput ... how come?

  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 11:11
    Martin
    0

    replacing $currentPage with current() actually gave me some output..



    but using current() should give me the axact same output ...

    How come it doesn't work that way ?!?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 25, 2009 @ 11:17
    Dirk De Grave
    1

    Hi,

    current() will only work in for-each loops I assume, whereas $currentPage is referring to the complete xml structure for the document being requested.

    Other option is to set the top level node id through a parameter in the macro (of type content picker) that references the xslt

    and add below statement near the currentPage param

    [code][/code]

    and use it in

    [code]

  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 12:09
    Martin
    0

    I assume that would work :)
    But it doesn't make sense to me, that current() only works within a for-each loop.

    Is there anyway I can retrieve a collection of nodes specified by their "document-type" or template ??

    [code]

    [/code]

    would this return the children of the root-node matching the given template/doctype??

    Regards,
    Martin.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 25, 2009 @ 12:26
    Dirk De Grave
    0

    Hi,

    Of course, it's just plain old xpath, just need to know how to build the xpath :p

    Here goes for what you're asking...




    Regards,
    /Dirk

  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 12:34
    Martin
    0

    Thanks alot :)

  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 13:49
    Martin
    0

    I've encountered a new "problem" ..

    Let's say I have a sitemap-structure looking alot like the one below.
    The menu I'm creating only gives me the childnodes of RootOfWebsite, not the descendants.
    I need to set an attribute class="active" on the "Home" link if it self or one of it's children = current(). I'm not sure if you can follow me here ...

    the menu would look like this:
    [ HOME ] [ Something2 ] [ Something3 ] [ Something4 ] etc.

    The "Home" needs to be underlined/active if it self or one of it's childnodes = current() ...
    does that make any sense ??
    Right now I'm only capable of checking if $currentPage/@id = current()/@id in my for-each loop.

    [code]
    +Content
    +RootOfWebsite (redirects to Home)
    +Home
    +page1
    +page2
    +page3
    +Something2
    +page1
    +page2
    +page3
    +Something3
    +Something4
    +Something5
    [/code]

    [code]

    [/code]

  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 13:53
    Martin
    0

    correction to the above XML ..

  • Martin 26 posts 21 karma points
    Mar 25, 2009 @ 14:07
    Martin
    0

    I guess the test should be:

Please Sign in or register to post replies

Write your reply to:

Draft