Needs review
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
Tokens
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
23 Sep 2021 at 20:45 UTC
Updated:
13 Feb 2026 at 15:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sam-tripp commentedComment #3
joseph.olstadGreat patch, confirmed that it works as intended! I've come across this use case before and wanted this functionality so great job! I think it's a worthy patch and looks perfect except just needs tests.
Needs tests ported from join-path tests so setting the issue to 'Needs Work'.
Comment #4
berdirThis would make more sense to me on the parents level aka parents-no-root, join-paths is an array-token and doesn't really have a meaning about root. If anything, it would be no-first then or something.
That also avoids the safe tokens problems because that part of the token is unchanged.
Comment #5
joseph.olstadGood point @Berdir , yes parents-no-root I agree.
we should look into making that change.
Comment #6
joseph.olstadok, ya parents-no-first is also a good suggestion for a name
Comment #9
mably commentedTried another solution by upgrading behavior of
join-pathtoken:join-path— works as before (all elements)join-path:1— skip first element (e.g., skip root parent)join-path:2— skip first twojoin-path:-1— last element onlyjoin-path:0:2— first two elements onlyjoin-path:1:1— second element onlyComment #10
mably commentedSome tests were added.
Comment #11
mably commentedSummary
Added optional array slice syntax to the
join-pathtoken, allowing users to exclude elements (e.g. root menu item) from generated path aliases.Problem
Users building menu-based aliases with
[node:menu-link:parents:join-path]had no way to exclude the root menu item from the generated path. The only option was to include all parent elements or none, which forced workarounds like manually removing the root item from the "Strings to remove" settings.Fix
switch/case 'join-path'with a regex match that accepts optional offset and length parameters using PHP'sarray_slice()semantics. The supported syntax is:join-path— all elements (backward compatible, unchanged behavior)join-path:1— skip the first element (the original request)join-path:2— skip the first two elementsjoin-path:-1— last element onlyjoin-path:0:2— first two elements onlyjoin-path:1:1— second element only