Copied to clipboard

Flag this post as spam?

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


  • Patrick 23 posts 83 karma points
    Mar 04, 2012 @ 13:43
    Patrick
    0

    write niceurl by nodeId

    I am looking for a method to insert a href where the niceurl and nodename are inserted by a nodeId.

    Being fairly new to Umbraco all help is appreciated.

    Tips on tutorials for this kind of actions are welcome to.

    Greetings Patrick

  • Asif Malik 203 posts 339 karma points
    Mar 04, 2012 @ 13:57
    Asif Malik
    0

    Hi Patrick. you should be able to use the following

    <xsl:value-of select="umbraco.library:NiceUrl('nodeID')"/>

    Replace nodeId with the integer value of the page id you want

  • Patrick 23 posts 83 karma points
    Mar 04, 2012 @ 14:12
    Patrick
    0

    Thanks for the reply, but maybe a noob question, when I use your example I get no result, but see the code in my html-source.
    It seems it doesn't get rendered, should I add something?

    My template is like this:

    <%@ Master Language="C#" MasterPageFile="~/masterpages/umbMaster.master" AutoEventWireup="true" %>
    <asp:content contentplaceholderid="cp_content" runat="server">

        <div id="page-bgtop">
          <div id="content">
            <div class="post">
              <h2 class="title"><span><umbraco:item runat="server" field="pageName"></umbraco:item></span></h2>
               <div class="entry">
                  <umbraco:item runat="server" field="bodyText"></umbraco:item>
               </div>
            </div>
          </div>

          <xsl:value-of select="umbraco.library:NiceUrl('1071')"/>

          <div style="clear: both; height: 1px"></div>
        </div>
     
    </asp:content>

     

    Greetings, Patrick

  • Asif Malik 203 posts 339 karma points
    Mar 04, 2012 @ 14:19
    Asif Malik
    0

    ah, I thought you were putting this in an XSLT file. To get this to work in a template file (masterpage) you will need to use the following code

    <%=umbraco.library.NiceUrl(1106)%>
    

    make sure you dont add the apostrohes around the number

  • Patrick 23 posts 83 karma points
    Mar 04, 2012 @ 14:59
    Patrick
    0

    Thanks, that's it.

  • Patrick 23 posts 83 karma points
    Mar 04, 2012 @ 15:18
    Patrick
    0

    Hmm, maybe a bit to early for my last response.
    I've searched for a likewise method to display the corresponding nodename, but can't find it.
    Can somebody still help me with that one?

    Patrick

  • Asif Malik 203 posts 339 karma points
    Mar 04, 2012 @ 17:16
    Asif Malik
    0

    I think you should look at putting all of this in an XSLT file and then wire up to your master page using a macro ...

    In the XSLT you will have the ability to create a variable whcih can store the XML data of a particular node

    <xsl:variable name="selectedNode" select="umbraco.library:GetXmlNodeById('String id')"/>

    Then you can do

    <xsl:value-of select="$selectedNode/@nodeName" />

    and

    <a href={umbraco.library:NiceUrl($selectedNode/@id)}>something</a>

    hoe that helps

Please Sign in or register to post replies

Write your reply to:

Draft