You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
{parent_uri} appends {mount} at every point in URI hierarchy, so with depth > 1 it starts to add up, e.g.:
given permalink structure /{mount}/{parent_uri}/{slug} it behaves like this:
1st level - /top/lvl1 (parent_uri = '')
2nd level - /top/top/lvl1/lvl2 (parent_uri = '/top/lvl1')
3rd level - /top/top/top/lvl1/lvl2/lvl3 (parent_uri = '/top/top/lvl1/lvl2')
How to reproduce
Orderable collection's route structure is '/{mount}/{parent_uri}/{slug}'
Create nested entries and check uri
publicfunctionbuild($route)
{
// Routes can be defined as a string for just the route URL,// or they can be an array with a route for each locale.$route = (is_array($route)) ? $route[$this->content->locale()] : $route;
$route = $this->convertToAntlers($route);
// keep {mount} only for the top level entries$routeData = $this->routeData();
if (isset($routeData['depth']) && $routeData['depth'] > 1) {
$routeData['mount'] = '/';
}
$url = Antlers::parse($route, $routeData);
// Slugify it because we're dealing with URLs after all.$url = $this->slugify($url);
// If provided variables had no matching value, we would end up with// blank spaces in the URL, possibly resulting in double slashes.// Tidying up the URL will de-duplicate those extra slashes.$url = URL::tidy($url);
$url = rtrim($url, '/');
returnStr::ensureLeft($url, '/');
}
The text was updated successfully, but these errors were encountered:
alexveklenko
changed the title
Strange urls: nested entries includes {mount} several times
Strange urls: nested entries include {mount} several times
Sep 25, 2024
Bug description
Problem:
{parent_uri} appends
{mount}
at every point in URI hierarchy, so with depth > 1 it starts to add up, e.g.:given permalink structure
/{mount}/{parent_uri}/{slug}
it behaves like this:1st level -
/top/lvl1
(parent_uri = ''
)2nd level -
/top/top/lvl1/lvl2
(parent_uri = '/top/lvl1'
)3rd level -
/top/top/top/lvl1/lvl2/lvl3
(parent_uri = '/top/top/lvl1/lvl2'
)How to reproduce
Orderable collection's route structure is '/{mount}/{parent_uri}/{slug}'
Create nested entries and check uri
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
Possible solution:
src/Routing/UrlBuilder.php
The text was updated successfully, but these errors were encountered: