This project is read-only.

Using autoroute

Topics: Writing modules
Mar 2, 2012 at 10:52 PM

I've just updated my Bing Map List module to work in Orchard 1.4. It was riddled with routable stuff.

Routable has been replaced with TitlePart and AutoRoutePart.

It all works, but when I create a new map area, fill in the title, but leave the permalink field blank so it uses the default pattern, it remains blank and the link becomes something like /Contents/Item/Display/13.

Do I need to do something to set a default pattern for my content type?

Or, is something else wrong.

Autoroute is working for blog posts so I assume it has something to do with my module.

Mar 2, 2012 at 10:54 PM

Can you take a look at the migration for Blog Post where it setups the settings the autoroute pattern ? Maybe you miss this part.

Mar 2, 2012 at 10:54 PM


                cfg => cfg
                    .WithPart("AutoroutePart", builder => builder
                        .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                        .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                        .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-blog'}]")
                        .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
                    .WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2"))
Mar 2, 2012 at 10:57 PM

Think I've found the answer poking around in the blog module migration file.

I've modified my migration to include this:

.WithPart("AutoroutePart", builder => builder
    .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
    .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
    .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-place'}]")
    .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))

Not sure what AutomaticAdjustmentOnEdit, or DefaultPatternIndex is, but it seems to have sorted it.

Mar 2, 2012 at 10:59 PM
Edited Mar 2, 2012 at 10:59 PM

Hi sebastien,

You're way too quick. I figured it out and posted my own answer, and then found you'd answered the question.

I should have looked there first, but hope having it online helps some other people.

Apr 10, 2012 at 5:28 PM

This post did help me. Thank you Richard and Sebastien. 

Here's some further clarification on the Autoroute Settings:

The setting for "AutomaticAdjustmentOnEdit" corresponds to the admin GUI checkbox on the Autoroute Part called - "Automatically regenerate when editing content" which is explained fairly clearly in the hint text below the checkbox.

An Autoroute Part may define a few different route patterns which are selectable via a radio button in the admin screens. This radio selection corresponds to the "DefaultPatternIndex". 

Aug 21, 2012 at 2:26 AM

Hi I was just wondering with the autoroute settings is there any way to prefix the path with something hardcoded?


i.e. i'd like to have all my blogs in the blogs section so I wanted to modify the default permalink for a blog to be something like Blogs/<permalink text field content>


how would i do something like that?



Aug 25, 2012 at 2:56 AM
Edited Aug 25, 2012 at 2:56 AM

You can modify the Autoroute pattern for your Blog content type to something like this: Blogs/{Content.Slug}