Hi,
I have a client who is very specific about SEO and they do not want the extra 301 when redirecting to a lowercase url. They want all the URLs in their site to be lowercase .
I have written a SQL script to convert the following values to lowercase:
CMS_Tree.NodeAliasPath
CMS_Document.DocumentNamePath
CMS_Document.DocumentUrlPath
CMS_DocumentAlias.AliasURLPath
However, if any document in the tree is updated or a new document is created then these values will not be lowercase anymore.
I then thought that I could do this in the document events so I created a custom handler with the following code
[OnDocumentCreated]
public partial class CMSModuleLoader
{
public class OnDocumentCreatedAttribute : CMSLoaderAttribute
{
public override void Init()
{
base.Init();
DocumentEvents.Update.Before += UpdateBefore;
}
void UpdateBefore(object sender, DocumentEventArgs e)
{
e.Node.SetValue("NodeAliasPath", e.Node.NodeAliasPath.ToLower());
e.Node.SetValue("DocumentUrlPath", e.Node.DocumentUrlPath.ToLower());
e.Node.SetValue("DocumentNamePath", e.Node.DocumentNamePath.ToLower());
}
}
}
The UpdateBefore method fires on every document update but the values do not get changed to lowercase. Am I doing something wrong here? Can these values not be updated?