1

I have a select list created by views exposed filters.

When I debug the templates used. I have the exposed filter template, then the select list is in a seperate template.

I tried just putting my html in the exposed filter around {{form}}. This put the html around the whole form, including labels, other containers etc, which didn't work for my situation.

So I am trying to target the select list directly using this answer here

function HOOK_theme_suggestions_select_alter(array &$suggestions, array $variables) {
  $routeObject = \Drupal::routeMatch()->getRouteObject();
  $view_id = $routeObject->getDefault('view_id');
  $display_id = $routeObject->getDefault('display_id');

  if (!empty($view_id)) {
    $suggestions[] = 'selectlist__' . $view_id;

    if (!empty($display_id)) {
      $suggestions[] = 'selectlist__' . $view_id . '_' . $display_id;
    }
  }
}

On first load of view it works. When I update the view using ajax the twig template is no longer loaded.

I check the template suggestions and it suggests the same twig template for before using ajax and after. I am at a loss on how I can edit the select list for a specific view whilst maintaining ajax use.

2
  • 1
    It's because of the route check - an AJAX call doesn't happen in the same route as the page it's called from (it'll be /system/ajax or something else)
    – Clive
    Commented Apr 21, 2022 at 14:17
  • What are you actually trying to output?
    – Jaypan
    Commented Apr 21, 2022 at 15:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.