Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/optional/pathauto.pattern.localgov_guides_page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
id: localgov_guides_page
label: 'Guide page'
type: 'canonical_entities:node'
pattern: '[node:localgov_guides_parent:entity:url:relative]/[node:title]'
pattern: '[node:localgov_guides_parent:entity:url:path]/[node:title]'
selection_criteria:
1ceaab92-3301-4e34-a8de-9dbcae184528:
id: 'entity_bundle:node'
Expand Down
22 changes: 22 additions & 0 deletions localgov_guides.post_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @file
* Post update functions for LocalGov Guides.
*/

use Drupal\pathauto\Entity\PathautoPattern;
use Drupal\pathauto\PathautoPatternInterface;

/**
* Update pathauto patterns to avoid inclusion of subdirectory, language, etc.
*/
function localgov_guides_post_update_pathauto_parent(): void {
$alias = PathautoPattern::load('localgov_guides_page');
if ($alias instanceof PathautoPatternInterface &&
$alias->getPattern() == '[node:localgov_guides_parent:entity:url:relative]/[node:title]'
) {
$alias->setPattern('[node:localgov_guides_parent:entity:url:path]/[node:title]');
$alias->save();
}
}