From 4f4d32077e579ccc25ceb93647522876547d4b68 Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Tue, 4 Aug 2026 10:58:19 -0300 Subject: [PATCH] Attempt at updating taxonomy term pattern. --- islandlives.module | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/islandlives.module b/islandlives.module index c78692c..5fefe6e 100644 --- a/islandlives.module +++ b/islandlives.module @@ -12,7 +12,7 @@ use Drupal\views\ViewExecutable; * Implements hook_pathauto_pattern_alter(). */ function islandlives_pathauto_pattern_alter(PathautoPatternInterface $pattern, array $context) { - // Only act on the repository_items pattern. + // Nodes: Only act if the pattern has machine name `repository_items`. if ($pattern->id() == 'repository_items') { // If node has no PID... $node = $context['data']['node']; @@ -23,6 +23,17 @@ function islandlives_pathauto_pattern_alter(PathautoPatternInterface $pattern, a $pattern->setPattern($new_pattern); } } + // Taxonomy Terms: Only act if the pattern has machine name `person_vocabulary`. + if ($pattern->id() == 'person_vocabulary') { + // If term has no PID... + $term = $context['data']['taxonomy_term']; + $pid = $term->get('field_pid')->value; + if ($pid == NULL) { + // Replace the PID with the TID in the alias. + $new_pattern = preg_replace('/\[term:field_pid\]/', '[term:tid]', $pattern->getPattern()); + $pattern->setPattern($new_pattern); + } + } } /**