sitefinitysitefinity-10

Use category name in Sitefinity blog URL


I followed the instructions here on establishing a new provider and generating custom URLs, and it works as expected. There doesn't seem to be a clear reference for what parameters can be utilized in the settings as the example given is very basic.

I want to use the category name of the post in the URL. I tried:

/[Category]/[UrlName]

but what I got in the frontend was:

http://localhost:60327/my-page/Telerik.OpenAccess.TrackedList%601[System.Guid]/my-post-name

I also tried

/[Category.Title]/[UrlName]

which just threw errors.

Anyone know how to do this, or better yet, a good reference for the parameters?


Solution

  • I don't think this is possible since the Category property is actually a collection (TrackedList). In theory you would need one of the collection items, let's say the first one, and your URL expression would be /[Category[0].Title]/[UrlName], but this is currently not supported by the expression parser.

    Also, the idea of making the URL dependent on a complex (related) field is not a good idea. If someone deletes that category, they will break all your blog post URLs.

    I would suggest you to create a custom text field for the blog post item (ex: CategoryUrl) and then you should be able to set the URL format to /[CategoryUrl]/[UrlName]. Make sure CategoryUrl field is required.