Needs work
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Jul 2021 at 14:45 UTC
Updated:
30 Apr 2026 at 10:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
dmitriy.trt commentedSubmitted an MR. It would be great to receive some feedback before further development, e.g. what should be done in order for the changes to be accepted & merged.
Comment #4
dmitriy.trt commentedUpdated the MR with the following changes:
Comment #5
berdirThere's at least one existing issue about this: #3077491: Add support for more advanced conditions. See my comment there as well.
Comment #6
dmitriy.trt commentedThanks for feedback! Yes, moving it to a sub-module sounds possible, but my time is limited right now, so maybe later.
However, some changes have to stay in the main module (API changes described in the issue).
Also, for the entity field conditions to work properly, you may need a fix submitted to #3187430: Pathauto checks for patterns before saving field values.
Comment #7
berdirYeah, not fixed on the submodule thing, I could also think of a setting, might be easier. But I think having this extended UI as an opt-in feature is important. Otherwise setting up basic patterns that are enough for most sites involves a lot more clicks and is much harder to do.
Or a hybrid mode, keep those two conditions as they are now but allow to add more with a button below.
Comment #8
dmitriy.trt commentedAdding a patch file here for a stable reference from composer files. It was made from MR!7 at commit
cd7daa6c.Comment #9
dmitriy.trt commentedPushed the following updates to the MR!7:
What could still be done to improve this MR and I plan to spend time on it, but not sure when:
Comment #10
dmitriy.trt commentedCompleted the following and pushed to MR!7:
It's only left to write some basic tests, at least from my point of view.
Comment #11
joao.ramos.costa commentedHi @Dmitriy.trt , thanks for the work. I've already had the chance to test if functionally and it seems to me ok. Here is a patch with reroll of merge request 7 against 8.x-1.10.Comment #12
joao.ramos.costa commentedComment #13
joao.ramos.costa commentedHi @Dmitriy.trt , thanks for the work. It's indeed very useful.
I've already had the chance to test if functionally and it seems ok to me. Here is a rerolled patch of merge request 7 against 8.x-1.10.
(I made a little mistake in the previous patch, here it is again.)
Thank you !
Comment #14
dtamajon commentedHi, I'm interested in that feature but trying to figure out how to add custom conditions from a custom module, as I need to add conditions based on my custom fields.
Do I have to follow some base class as in Rules module?
Comment #15
joao.ramos.costa commentedHi @dtamajon you can create a class that extends ConditionPluginBase.
Have a look https://gist.github.com/acrosman/ab7e9ffce3996f6bc1798f9f1ca34c06. Cheers
Comment #16
dtamajon commentedThank you!
Comment #17
dtamajon commentedI tried to add conditions successfully (custom ones and default ones) and works perfectly.
Comment #18
dieterholvoet commentedComment #19
dieterholvoet commentedI had to fix a couple things to make it work on Drupal 10, but apart from that this feature seems to be working! @Berdir, could you comment on whether or not this feature should live in a submodule? That way we know how to move this forward. Since this feature has lived in this MR for two years already and it seems to be working great, I'm considering creating a new project for the submodule so that people can start using it.
Comment #20
uberengineer commentedRe-rolled patch 13 for Drupal 10
Comment #21
uberengineer commentedPatch #20 does not apply due to whitespace #21 applies
Comment #23
max.valetov commentedAdds a D10 session check and set for subrequest to patch 21
Comment #24
max.valetov commentedFixes patch formatting issue for patch 23
Comment #25
max.valetov commentedFix 'non-scalar value' error - patches 21-24
Comment #26
bkosborneThis is fantastic! Thanks for working on this. I may have time to contribute as well.
One change I think this needs is to disable the default, hard-coded conditions UI that pathauto already provides for specifying language and content type. I think that if this sub-module is used, then all conditions should be managed by it.
Comment #27
bkosbornePlease, let's keep all work in the merge request. The last three patch files are especially problematic because they don't include an interdiff.
Comment #28
bkosborne[double post]
Comment #29
bkosborneWhile this is working well, it exposes a problem with the PathautoWidget. The form widget disables Pathauto if there isn't a matching pattern for the entity. But if you have only a single pattern defined and that pattern has a condition based on data from the entity, when you go to create a new Page node, the Pathauto checkbox won't be there and it won't be activated.
To resolve this, you need to create a fallback pattern that is activated for the content type without any data-based conditions. Then the widget will show the checkbox to activate pathauto.
Once the node is saved and has the required data, pathauto will re-evaluate the patterns for the node and choose the pattern that has the data condition. Though, in testing I found that you need this patch too: #3187430: Pathauto checks for patterns before saving field values
To be clear, the conditions UI that this patch provides is working as expected, it just exposes some additional challenges when using data-based conditions.
Comment #30
bkosborneComment #31
dieterholvoet commentedThere seems to be an issue since the changes that were done in the past months: when updating an existing condition, it's being duplicated instead of the existing one being updated.
Comment #32
siliconandincense commentedHi folks!
Sorry for the beginner question but I don't have a huge amount of experience when it comes to anything more complicated than pulling in a patch.
With the release of the pre-crimbo commits do I need to manually roll a patch myself from the HEAD of this branch to get this feature D11 ready, or is there another way to do it?
Thanks for your patience!
Comment #33
bkosborneYou should click the "plain diff" link next to the merge request link (top of the issue on this page). It generates a git patch file. You should copy the contents of that into a plain text file in your project and include it with composer patches. Looks like it's already D11 compatible.
The thing holding up this issue is the lack of tests.
Comment #34
siliconandincense commentedFantastic, thanks ever so much for the reply, ill give that a go :)
Comment #36
mably commentedComment #37
mably commentedComment #40
mably commentedCreated a new MR from the original one to enable Tugboat.
How are we supposed to test the new UI? Not seeing anything.
EDIT: My bad, I forgot to enable the
pathauto_condition_uisubmodule.Comment #41
dieterholvoet commentedI started a separate module project for this feature: Pathauto Conditions UI. I added @dmitriy.trt and @bkosborne as maintainers since they contributed in a significant way to the MR here.