2

I often use a 'site' template group to house my base level pages. For example I may have a 'about' page, but don't require an 'about' template group so I add this to the 'site' group. I then don't want the URL to be /site/about so I have always used the plugin 'freeway' to allow me to remove the 'site' part (domain.com/about).

Now that 'Template Routes' has arrived, I have begun using this by setting '/about' as the route for the page. This works perfectly.

The problem I have is that on occasion I add a segment on a page to show additional information when a user clicks a link. For example 'about/more-content'. Now with template routes this extra segment stops the page from working and shows the 404 page.

Is there a way to have '/about' as the route, but also allow for extra segments after?

Thank you

1
  • 1
    Seems like it'd be a lot simpler to just have a few more template groups...;) Jul 11, 2014 at 14:41

1 Answer 1

4

Yup - make sure you set "require all segments" to "no", then just add another segment to the rule:

/about/{extra:alpha_dash}

:alpha_dash means that the segment can contain alpha-numeric characters, underscores, and dashes. There are other rules available as well.

Then in your template you can check the value of the extra segment this way:

{if segment:extra == 'foo'}
    // Show something different
{/if}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.