Copied to clipboard

Flag this post as spam?

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


  • Touhid 97 posts 117 karma points
    Dec 28, 2010 @ 10:48
    Touhid
    0

    how to get current dynamic node id in a template

    Hi

    Suppose, i have the following node in a content section:-

    ->Product

    ->Sales

    ->Purchase

     and i used a template like as:

    <a id="ShowLink"  href="product.aspx?">Product</a>

    This code is only for product node. But i want to that template is used for every templte. which i cant. can anyone help me. how to do this??

    Touhid

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 28, 2010 @ 10:55
    Dirk De Grave
    0

    touhid58,

    use

    <a id="ShowLink" href="<%=umbraco.library.NiceUrl(id)%>">Product</a>

    and replace 'id' with the id of the 'Product' node in de content section (hover over the node and have a look at the lower left corner, should see a openContent(id)).

    Is it that what you're after? If not please elaborate.

    Cheers,

    /Dirk

  • Touhid 97 posts 117 karma points
    Dec 28, 2010 @ 11:26
    Touhid
    0

    Hi Dirk

    Thnks for reply but it doesnt work.

    Suppose, i have the following node in a content section:-

    ->Product

    ->Sales

    ->Purchase

     and i used a template like as:

    <a id="ShowLink"  href="product.aspx?">Product</a>

    Here the code is work for product node, and it is ok. That means it is static for product node. But i want that code will work for every node( product, sales, purchase) using this same.

    Touhid

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 28, 2010 @ 11:33
    Dirk De Grave
    0

    so you want all nodes 'Product', 'Sales' and 'Purchase' on the page with their corresponding hyperlinks? May need to tell a bit more on the context before we can actually give some code to put in the template.

    Are these nodes part of a navigation, which you need on all pages? Please explain in greater detail, there's probably a thousand ways to do it, but depending on your needs and context, the solution may vary.

    Most simple solution that'll work on all pages:

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = 1]/*>
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a>
    </xsl:for-each>

    Code snippet traverses the content node starting from the requested page up to level 1 (which is the 'Content' node) and outputs all child nodes with their corresponding link and name

    You must of course have an xslt file and a macro that references this xslt and put that macro onto the page. If you're not familiar with this, have a look at the intro videos on umbraco.tv for inspiration

    Cheers,

    /Dirk

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies