For various reasons, I need to save the URL-Slug for a new node, as the node is being saved, in a separate area, and need to ensure the same rules are applied for sanitizing it, so that it exactly matches the URL-Slug generated by Umbraco when saving the node.
I assume there is a callable API function to process the node-name to a URL-Slug - i.e. the Umbraco 'Slugify' utility - but finding it is another story.
So if you have the string representation of the name of the node that you are creating, the url slug should be just the result of calling ToUrlSegment() on it
I read the code, and it has it's own way of handling UTF8 - finding definitive rules on this and diacritic handling is a real can of worms - but so long as I'm doing it the 'Umbraco' way, that's all that matters to me.
API to generate URL-Slug from Node-Name
For various reasons, I need to save the URL-Slug for a new node, as the node is being saved, in a separate area, and need to ensure the same rules are applied for sanitizing it, so that it exactly matches the URL-Slug generated by Umbraco when saving the node.
I assume there is a callable API function to process the node-name to a URL-Slug - i.e. the Umbraco 'Slugify' utility - but finding it is another story.
Anyone?
Hi MB
There is an Extension method called ToUrlSegment()
https://github.com/umbraco/Umbraco-CMS/blob/v7/7.15.4/src/Umbraco.Core/StringExtensions.cs#L1222
In the Umbraco.Core namespace
So if you have the string representation of the name of the node that you are creating, the url slug should be just the result of calling ToUrlSegment() on it
regards
marc
Excellent - exactly what I needed.
I read the code, and it has it's own way of handling UTF8 - finding definitive rules on this and diacritic handling is a real can of worms - but so long as I'm doing it the 'Umbraco' way, that's all that matters to me.
Cheers.
is working on a reply...