To add Zero coding wildcard routing to Umbraco 6 and 7. Allow upto 5 extra parameters added to any existing content without writing any controllers or extra route handling. Simple out-of-the-box behavour, that is controlled by the simple inclusion of extra labels added to your existing doc type.
What about multiple wildcard slugs like www.mysite.com/search/text/20/30
1. Install package.
2. Add a new label with an alias of ‘umbracoParam1’, 'umbracoParam2', 'umbracoParam3', 'umbracoParam4' or 'umbracoParam5', to any Document Type that you use as the basis of a page that requires routing. For example if your Search template uses a Document Type called Search, then this is where you add the new label too. The label itself is just a marker to AutoRouteTemplate, to signify that you want this template to auto route and not other templates. Which label you pick defines how many extra parameters it can handle with 'umbracoParam1' allowing one wildcard parameter
3. In the template, use the code
var query = this.UmbracoParam()
this will store the extra parameter/actions in the query array variable, which you can use like any other variable. If the action was never called, query will equal null.
4. Can be used using controllers - TODO: Tell people how to do this
The package contains a
single dll assembly that is installed in the Umbraco /bin/ folder. At initialisation
every DocType within your project is examined for the existence of the
umbracoParam1 alias property and using the powerful Umbraco IContentFinder
class whenever a non standard request is processed, the request is checked
against the valid DocTypes and the template is executed as normal with the action stored within the page session variables.
this.UmbracoParam() is an extension method for HttpCurrent.Current.Items[“umbracoParam”];
Tested with Umbraco 6.1.3 & 7.1.4
1. Create a member called 'admin'
2. Create a Document Type called ‘Member’, accept creation of matching template called 'Member'
3. Add a new label to Document Type with the alias of 'umbracoParam1'
4. In the new Template called ‘Member’, copy and paste the following Razor code:
string query = this.UmbracoParam();
var member = UmbracoContext.Application.Services.MemberService.GetByUsername(query);
if (member == null)
4. Create new content based on new Member Document Type.
5. View your new content, but add /admin on the end of the URL