This project is read-only.

Autoroute Part - slug generation query

Topics: Core, Writing modules
Apr 10, 2013 at 1:14 PM
I have been working with some content types and noticed that I couldn't get to them via the slug that was had been generated from the title.
On looking at it, some of my titles had the % symbol in it, which doesn't look like it was being replaced (like spaces etc).
Having looked in the Orchard.Autoroute.Services.DefaultSlugService the Slugify method doesn't indeed contain this symbol, it only has;

var disallowed = new Regex(@"[/:?#[]@!$&'()*+,;=\s\""\<>\\|]+");

Should it not be in, or is there a reason for it?

Now going forward.. I can simple modify this for my purpose, but am I able to override this in my own module rather than modifying the Core code?

Apr 10, 2013 at 1:20 PM
Edited Apr 10, 2013 at 1:21 PM
I think the % should be added to the list, but I don't know enough to be sure.
In any case, you can implement your own SlugService by implementing the interface and decorating your class with the OrchardSuppressDependencyAttribute, suppressing the DefaultSlugService.

You may want to file a bug about this so we can discuss and decide whether or not we should add % to the disallowed list.
Apr 10, 2013 at 4:39 PM
Ah ok, where do I go to file a bug?

Will take a look at the suppressattribute - I've been wanting to give that a go.
Apr 10, 2013 at 5:25 PM
Awesome. You can file issues via Issue Tracker (next to Discussions and before People) ->
Apr 15, 2013 at 4:55 PM
I have tried to create my own SlugService, at the top of my service class I have put


But mine never gets called, always the original one, have I missed something?
Apr 15, 2013 at 5:42 PM
Make sure that you implement the ISlugService interface and that your feature is enabled. Also check your log files to ensure that there aren't any errors with your module.
Apr 16, 2013 at 10:11 AM
Oh dear... I hang my head in shame..

My code was perfect, I forgot to enable my module, in my defence yesterday was a long day!

Works perfectly, OrchardSuppressDependency is quite a cool feature.