Reputation: 1350
How can I change all URLs to uppercase / lowercase, or change the default naming convention?
Eg. from:
http://our.umbraco.org/projects/backoffice-extensions/
to:
http://our.umbraco.org/Projects/Backoffice-Extensions/
Upvotes: 1
Views: 1109
Reputation: 3447
This is not so hard if you know how to program C#.
You basically need to write your own UrlSegmentProvider (see documentation).
public class UppercaseUrlSegmentProvider: IUrlSegmentProvider
{
private readonly IUrlSegmentProvider provider = new DefaultUrlSegmentProvider();
public string GetUrlSegment(IContentBase content)
{
return this.GetUrlSegment(content, CultureInfo.CurrentCulture);
}
public string GetUrlSegment(IContentBase content, CultureInfo culture)
{
// Maybe you don't want to do that for all contentTypes
// if so, check on the contentType: if (content.ContentTypeId != 1086)
var segment = this.provider.GetUrlSegment(content);
// for the sake of simplicity I have put everything in uppercase,
// you could of course implement something like this:
// http://www.java2s.com/Code/CSharp/Data-Types/CamelCase.htm
return segment.ToUpper().ToUrlSegment();
}
}
To activate your segment provider, you can use the ApplicationStarting method of the ApplicationEventHandler.
public class MySegmentEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarting(umbracoApplication, applicationContext);
// UrlSegmentProviderResolver.Current.Clear();
UrlSegmentProviderResolver.Current.InsertType<UppercaseUrlSegmentProvider>(0);
}
}
Attention, if you have implemented the code above, the existing nodes won't change automatically. It's only after a "Save And Publish" that your URL of the particular node will have it's new "segment".
Upvotes: 2