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?
@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());
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
Hi Jeroen,
use the Node.Text property. That is the same as urlName in XSLT.
Peter
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
@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:
well, there's another option (looking at the code for v4.5, but it's quite similar to 4.x)
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
is working on a reply...