Routing

Core dna offers custom routing to select modules within the system. 

For custom routes to work the centre option seo-url must be removed and the routing centre option must be added, you can restore the original routing at any time by re-adding the seo-url option, this takes priority over the routing centre option. The route template helper will work for both so no template changes will be required when switching.

Setting up custom routes

You can set up custom routes in the admin_routing section of the Core dna DXP. 

By default the list will show the prefixes we currently use, if you modify a prefix it will show the modified prefix, display a custom flag and allow you to go back to using the default at any time.

Adding a custom prefix is as simple as editing the module you want to change and giving it a new prefix. All prefixes added will be 'slugified' which means invalid characters will be converted to URI replacements.

Using custom routes in remplates

Templates have been given a new helper route, to use this helper convert your URLs so they're relative to the module and use the module key to generate the full URL.

<{route('products', 'category/17')}>

The code above will generate the URL http://<sitename.com>/<prefix for products>/category/17. If you want to pass multiple parameters because you need to concatenate a string or similar you can also use an array

<{route('products', ['category', $category.id, 'view'])}>

The code above will generate the URL {{http://<sitename.com>/<prefix for products>/category/17/view}} assuming that $category.id is 17.

SEO priority

Some sites will want to prioritise a module above others, you can do this by removing the prefix entirely from one module.