Updating autorout URL from C# code in ORCHAD CMS

56 Views Asked by At

I have built a simple website and have the requirement to display all post from a blog for a year.

For example www.mysite.com/blogs/2015 should display all posts of 2015. However, this year is not the real creation date of the post but it is given as input while creating the post (I have added new field to the editor).

I should also have a way to access a post with a unique URL like www.mysite.com/blogs/2015/2, which should display the second post of 2015. The post number is unique for the year. So I cannot use the content id.

I was able to make this work with my own controller, but an issue remains: When posts are listed it will attach the URL created by the AutoroutePart, which will be like www.mysite.com/blogs/first-post.

I attempted to change this URL while creating the post by updating the Path property of the AutoroutePart but had no luck.

Any suggestions or advise are appreciated.

1

There are 1 best solutions below

0
humanoidcreature On

You can define you own route for any content item which has the AutoroutePart.

Example in you situation you need to edit the content definition of the blog posts. So under the Content Definition menu you select Blog Post, then edit, then you click on the expando arrow next to the Autoroute label and you'll see the Patterns field where you can define your own pattern.

Url patterns