I started adding patterns for node types, and I was really confused by the UI: when I add a node pattern, I pick the node type or leave it blank. But clearly I could add more than one pattern with the same node type condition, or with no node type condition.

What would happen in this case -- how would new nodes get handled?

I assume that the order of the patterns at admin/config/search/path/patterns is what counts, and that the first pattern that matches is the one that is used to generate the path. The form here could really use some hook_help() text to explain this.

Issue fork pathauto-2809449

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

lpsolit’s picture

Actually, the opposite is true. The last applicable pattern in the list is the one being used, see getPatternByEntity(). So patterns behave like CSS cascading where a rule overrides previous ones. Not sure why Pathauto was initially designed to allow several patterns for the same content type when only one can be used at once.

I agree that this is not intuitive and that the text at the top of the page should be clearer about it. Also, this behavior should be tested in a test, maybe PathautoUiTest.php?

berdir’s picture

Not sure why you think it is the last, maybe you missed the break in the loop? The first one that matches is used, definitely, and we have tests for that, for example in \Drupal\Tests\pathauto\Kernel\PathautoKernelTest::testPatternLoadByEntity()

Internally, we use the generic conditions API, we just expose it in a simplified way. However, if you have a multilingual site, then we also allow to configure it per language. So having multiple per content type, one per language is perfectly valid. You could also use other condition plugins, but we don't fully support that yet.

lpsolit’s picture

Hum, I have been confused by the patterns list. I created 2 patterns for a given node bundle, and the 2nd one was the one being used. I just looked at the weight column, and both patterns have the same weight (not sure why the UI didn't give a different weight to them), so that probably confused things a bit. I reordered the list, and now they have a distinct weight and things are working correctly: the first pattern is the one being used. Sorry for the confusion!

kpaxman’s picture

I was just looking for the answer to this as I was trying to figure out how I could set a rule for a specific taxonomy without having to specify all the other taxonomies in my "generic" rule (since I want any newly-created taxonomies to follow the default rule).

Text like "If more than one pattern rule applies to a given piece of content, the earliest rule in the order will be used." would have been very helpful. :)

bkosborne’s picture

mably’s picture

Issue tags: +good first issue

Looks like we need an MR for this.

mably’s picture

Category: Bug report » Task
Status: Active » Postponed (maintainer needs more info)

We need a good suggestion for the text to update.

kpaxman’s picture

FWIW I had suggested "If more than one pattern rule applies to a given piece of content, the earliest rule in the order will be used." but maybe this is you saying that's not right or not sufficient. :)

Or are you asking where it should go? If so, my suggestion would be for this help text to appear at the top of the "patterns" page at admin/config/search/path/patterns