Search code examples
pyrocms

PyroCMS: How Do I Create a multi Segment URL ?


I want my url to be like this:

mysite.com/categories/roofing

I can achieve this by creating a new navigation group called categories and make roofing a child BUT I do not want a new Navigation group. I want to be able to call a specific function by identifying segment 1 while still having the url include segment 2.

I tried doing it in "Page Types" but it will not allow you to create a multi segment slug.

I have the stream module if that helps.

Many Thanks !!


Solution

  • This is actually really simple and there are a few ways to do it. The simple way would be to create a page with the slug categories (you can redirect this page using routing later if you don't want it to exist), and then create a page with the slug roofing. Finally, in the pages section of the admin, drag roofing under categories as a child.

    This can also be done using routing. You would create a routes.php file with the config folder with the following:

    $route['categories/(:any)'] = '$1';