Search code examples
url-rewritingkentico

Setting a url pattern for all new instances of a specific page type in Kentico?


I've got a custom page type (olliEvent) that end users use to make new events in our Kentico 9 CMS. Because of the way our site is built, the url path that would be generated from the site tree would be incorrect. I need to automatically set a custom url path each time the end user creates a new olliEvent page. These pages have exclusive use of the olliEvent page type and a olliEvent page template, so we can set parameters on those if we need to.

The file tree is: /subsites/olli/class-listing/(pageName)

I'd like for the url to be: /olli/class-listing/(pageName)

I can think of two ways to approach this:

1) Exclude the "subsites" folder when creating urls based on the file tree. Is there a way to do this?

2) Make some sort of macro type url that is set at the page type or page template level. Is this possible?

Thanks! Todd


Solution

  • One way you can do that is to create a Event Handler for this page type, so when this page type page is created/updated, the event handler will set the URL path/pattern to /olli/class-listing/(pageName)

    https://docs.kentico.com/k9/custom-development/handling-global-events