From f9c84231a10352714507ba50a3c1747fa144e850 Mon Sep 17 00:00:00 2001 From: Rupert Jabelman Date: Tue, 22 Oct 2024 10:33:53 +0100 Subject: [PATCH] Removed URL fragment from template and moved it to a guides specific preprocess, so it only appears on guides. --- localgov_base.theme | 13 +++++++++++++ templates/_components/prev-next.twig | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/localgov_base.theme b/localgov_base.theme index f5106ce7..006ff6e5 100644 --- a/localgov_base.theme +++ b/localgov_base.theme @@ -8,6 +8,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\DeprecationHelper; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Url; use Drupal\views\ViewExecutable; /** @@ -248,3 +249,15 @@ function localgov_base_preprocess_container(&$variables) { function localgov_base_form_preview_link_entity_form_alter(&$form, $form_state, $form_id) { $form['#attached']['library'][''] = 'localgov_base/preview-link'; } + +/** + * Implements hook_preprocess_guides_prev_next_block(). + */ +function localgov_base_preprocess_guides_prev_next_block(&$variables) { + if ($variables['previous_url'] instanceof Url) { + $variables['previous_url']->setOption('fragment', 'lgd-guides__title'); + } + if ($variables['next_url'] instanceof Url) { + $variables['next_url']->setOption('fragment', 'lgd-guides__title'); + } +} diff --git a/templates/_components/prev-next.twig b/templates/_components/prev-next.twig index 3f3f90a4..ea1954e3 100644 --- a/templates/_components/prev-next.twig +++ b/templates/_components/prev-next.twig @@ -25,7 +25,7 @@