Future Orchard Part 3: Autoroute

The way URLs work in Orchard today is fine for the simplest sites but it's not very customizable and comes with a number of challenges. Let's look at how it works today. Let's start with a plain page:image

Once you're done typing a title, when you tab out of the title field, an ajax request is fired that asks the server to do a fake publication of the page and get a slug out of the title. This happens in the Routable part, and it is extensible by implementing ISlugEventHandler. There are a few problems with this.

First, the fake publication is creating some noise for subscribers to the publication event. It would be better unfortunately to do away with the nice ajax behavior.

Second, it becomes really hairy once you introduce containers, such as lists or blogs. Should the path of the contained object begin with the path of the container? Should the path recursively include the slugs of all parent? When the path of the parent changes, does that mean the paths of all children change?image

We had to come up with answers to all those questions and more, but the problem is that the answers we came up with are fixed and there will always be people who disagree and they would be right.

This is why we are revising the whole URL infrastructure to make it highly configurable, a feature that we call Autoroute. Mockups here are far from final by the way, so don't focus on UI or wording.

There will be a new setting on the Routable part type, so that you can go to the content type editor and choose which pattern to use for each routable content type:image

Once you've configured your content type to use a specific pattern, the content editor will have something like this:image

If you leave the checkbox checked and save, the pattern will get applied and you will get something like this:image

Now if you uncheck the checkbox, then the path becomes editable and you can set it to just about anything.

The set of patterns that you can use is configured on a separate settings screen. There, you can create named patterns using Tokens:image

Finally, there is a third screen where you can find the full set of all paths that were generated.image

This will enable you to recalculate paths in bulk. This is necessary because we made the choice this time around that once a pattern has been applied to generate the path for a content item, that path is fixed. If the path to the container changes for example, and the pattern you used depended on the container slug, then the contained items won't change unless you make the conscious decision to reapply the pattern.

Of course, this is all built on top of highly extensible APIs that can enable replacement of part or all of the UI and behavior above, but this is what the feature should look like to users out of the box.

19 Comments

  • very good.

    when orchard 2.0 come?

  • Early Spring 2012.

  • Looking forward to it! really good.

  • Just wanted to say that I really like this new approach to routing / url generation! Now the tokens feature makes even more sense to me as well.
    Already can't wait for 2.0!

  • preview version for 2012? or release version
    i cant't wait too .hehe

  • Release.

  • have the plan for preview version? and when?

  • First preview will be around September.

  • Thanks for sharing your thoughts on Autoroute here - great to see what you guys are thinking about for this important feature.

    This is the one remaining reason I've yet to port my own blog from BlogEngine.NET to Orchard ...

    ... well, this and the issues I'm experiencing with Orchard's current pagination issues.

  • Oh ... and are you using Sketchflow to prototype the UI here?

  • @Richard: no, that's Balsamiq.

  • Can you please make the url much more customizable? say if my site has several language versions, and the content's going to have several titles repectively for each language version, I'd like the url for each language version be different just based on each of the language version's title.

  • Also, can you please make the date time format more localizable on the admin ui rather than hard coded it in the code like this? This makes the translated datetime format much less human friendly. I think you can copy the way ScrewTurn wiki handles datetime format when setting up a new wiki.

    public static LocalizedString DateTime(this HtmlHelper htmlHelper, DateTime value) {
    //TODO: (erikpo) This default format should come from a site setting
    return htmlHelper.DateTime(value.ToLocalTime(), new LocalizedString("MMM d yyyy h:mm tt")); //todo: above comment and get rid of just wrapping this as a localized string
    }

  • Also can we work around a better way to handle the orchard localization? currently the localization works like word by word translated which really makes the final translated words unreadable in its context, I mean can we do it pattern by pattern with the some context info included rather than word by word, which might make more sense to help people spread this great work to every corner of the world.

  • @Shawn: yes, the localization part can expose tokens that you will be able to use int your URL patterns.

    For the date time format in the admin, a patch would be more than welcome.

    Finally, what do you mean by "word by word translated"?

  • "word by word translated": say for example, if we go to the installed themes, there are the authors' names right under the themes' names, and it goes like "By jowall, mibach, loudej, heskew" and here the word "by" is always translated separately, and that would be impossible for the user to figure out what it really means.

  • No, that's not true. Translations are full sentences and they have the context of what file they were defined in right next to them. I'm wondering what could have given you that impression.

  • I understand that what you have described here would provide flexibility and power and I am so pleased at Orchard's priority to just getting the code really good so it can be built on. Wouldn't it also be cool to have a tree view showing all the different routes for the website presenting the content for the website just like good old windows explorer?
    Is something like that on the cards?

  • @Ben: there is a new route debugging module on the gallery that you will probably like then...

Comments have been disabled for this content.