When using routes the $page->url()
can be wrong in the templates/snippets/patterns. I have an idea that it might be possible to use a model to fix it by using the route patterns.
- Would it be possible to extract the regex from the routes in a model?
- Would it be a good idea to solve it like that? Or would it be too complex or slow?
Something like this?
foreach( $route->patterns as $pattern ) {
if( preg_match($pattern, $page->url() ) ) {
$page->url = preg_replace($pattern, $page->url());
}
}