Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 29, 2010 @ 14:24
    Jeroen Breuer
    0

    XSLT urlName in C# Node object

    Hello,

    In XSLT the urlName is available, but the Node object in C# doesn't have a property with the urlName. Is there a way to get the urlName or do I need to write my own code which convert's the node Name property to the urlName?

    Jeroen

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jun 29, 2010 @ 14:30
    Peter Dijksterhuis
    0

    Hi Jeroen,

    use the Node.Text property. That is the same as urlName in XSLT.

    Peter

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 29, 2010 @ 14:33
    Dirk De Grave
    0

    Don't you just need to use the umbraco.library.NiceUrl() function, which takes the id of the node as the input parameter and generates the url?

     

    Cheers,

    /Dirk

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 29, 2010 @ 14:51
    Jeroen Breuer
    1

    @Peter the node doesn't have a Text property.

    @Dirk I don't need the full url, but just the url name (without all the parent node names in the url).

    For now I solved it by using some pieces of the source code:

    using umbraco.cms.helpers;
    
    Node node = Node.GetCurrent();
    
    //Get the url name like it's stored inside Umbraco.config.
    string urlName = url.FormatUrl(node.Name.ToLower());
    

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 29, 2010 @ 14:58
    Dirk De Grave
    0

    well, there's another option (looking at the code for v4.5, but it's quite similar to 4.x)

    content.Instance.XmlContent

    which returns an XmlDocument you can query using an xpath expression to get the urlName attribute from a specific node.

     

    Hope this helps.

    Regards,

    /Dirk

     

Please Sign in or register to post replies

Write your reply to:

Draft