I think this would definitely take some custom code to be written. One simple approach might be to have a publishing event that populates this field on
I'm not sure I've really understood the question properly, at least when I've finished what I've done it doesn't make much sense to me, but then I'm not an SEO expert, this will now give you an alternative URL in upper case, but the URL is not case sensitive anyway. Anyway I've done it...
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
public class SaveEvent : ApplicationEventHandler
{
public SaveEvent()
{
ContentService.Publishing += ReplaceProperty;
}
private void ReplaceProperty(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
foreach (var node in args.PublishedEntities)
{
string pageName = node.Name;
if (node.HasProperty("umbracoUrlName"))
{
node.SetValue("umbracoUrlName",pageName.ToUpper().Replace(" ","-"));
}
}
}
}
I've also created a visual studio project which you can compile and save the DLL into the /BIN folder of your site. You can download this from here:
if you put the DLL (from the bin folder) in the BIN folder of your site and your document type has a property called umbracoUrlName (the casing of the alias is important) then when you publish the node of that document type then the property will be replaced with the page name in upper case with the spaces replaced with hypens
It doesn't work for me. I have the propery "umbracoUrlName" set in Master document type, so all pages inherit this propery. This is the steps I made, please tell me what am I missing:
Created the "SaveEvent" class in "App_Code" folder:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
namespace MyProjectName.App_Code
{
public class SaveEvent : ApplicationEventHandler
{
public SaveEvent()
{
ContentService.Publishing += ReplaceProperty;
}
For the dll to work it would need to be in the /bin folder of your site.
If you are building a project which is placing a dll into the /bin folder of your site then the best way to include this would be to include this class into any project which builds into the bin folder of your site.
You can debug this by attaching to the w3wp.exe process within visual studio and setting a breakpoint within the class above, This will then tell you if the problem is that the event is not firing, or if it is firing then if there is a problem with naming etc.
Populate umbracoUrlName properties with their uppercase page names
The default URL naming convention is the page node name in lower case.
How can I populate all umbracoUrlName properties of all pages (except home page ) to their uppercase page name in content tree with a dash between words? I'm trying to change the names of the URI segments to uppercase from http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/NewTopic to http://our.umbraco.org/Forum/Umbraco-7/Using-Umbraco-7/New-Topic for SEO purposes. Something like in the last post from this topic: http://our.umbraco.org/forum/developers/extending-umbraco/7769-URL-rewriting-for-SEO-purposes
I think this would definitely take some custom code to be written. One simple approach might be to have a publishing event that populates this field on
save. http://our.umbraco.org/documentation/Reference/Events-v6/ContentService-Events
Can you give an example?
OK give me a minute or two and I'll have a go
ok, thanks
I'm not sure I've really understood the question properly, at least when I've finished what I've done it doesn't make much sense to me, but then I'm not an SEO expert, this will now give you an alternative URL in upper case, but the URL is not case sensitive anyway. Anyway I've done it...
so i shoud add this class somewhere else or just adding it to the ptoject and build it will work?
if you put the DLL (from the bin folder) in the BIN folder of your site and your document type has a property called umbracoUrlName (the casing of the alias is important) then when you publish the node of that document type then the property will be replaced with the page name in upper case with the spaces replaced with hypens
or I think you could place this code as a class in the app_code folder which would do the same thing
do I need to include (by right clicking > include in priject) the dll in the project? the rest of dll from bin are not included.
you mean the "CopyProperty.dll" ?
yes that is the correct dll
know you don't need to include it in the project
although you could include the source to build into your project
you don't need to reference it
it's just a self contained lirttle program doing that thing for you
it could easily be a part of another project though
It doesn't work for me. I have the propery "umbracoUrlName" set in Master document type, so all pages inherit this propery. This is the steps I made, please tell me what am I missing:
Created the "SaveEvent" class in "App_Code" folder:
Copied the dll "CopyProperty.dll" from your project's bin folder into my project's bin folder, didn't inlcude in project, build the project.
BO: Right click Home node > Publish Home and all subpages, also right click on Content > Publish entire site.
After this, "Link to document" property is the same (lowercase), and "umbracoUrlName" prrperty is not populated.
What am I missing?
Thanks.
I'm not sure how your project is set up.
For the dll to work it would need to be in the /bin folder of your site.
If you are building a project which is placing a dll into the /bin folder of your site then the best way to include this would be to include this class into any project which builds into the bin folder of your site.
You can debug this by attaching to the w3wp.exe process within visual studio and setting a breakpoint within the class above, This will then tell you if the problem is that the event is not firing, or if it is firing then if there is a problem with naming etc.
is working on a reply...