I am trying to create theme suggestions function for pagers in my *.theme. Is this possible in Drupal 8? If it is possible, what is wrong with the following code? Is suggestions_pager_alter the right way to access the hook call so I can add a theme suggestion to a page, so I can override the template. I am not worried about the functions logic.

function mytheme_suggestions_pager_alter(array &$suggestions, array $variables) {
  // Add template suggestions based on the current view mode.
   print_r(); exit;

  • There isn't much in the function you are showing. If you are asking if that is the correct way to check a hook is invoked, then no, it isn't. A part that, is there something more specified you are worried about?
    – apaderno
    Apr 26, 2017 at 8:47
  • If you want to check if the function ran use drupal_set_message('yes it works!!!', 'warning'); instead of print_r(); exit;. You should get the yellow warning message if it ran.
    – No Sssweat
    Apr 26, 2017 at 11:08

1 Answer 1


mytheme_suggestions_pager_alter is the correct way to use the hook. The issue was my pager in the view footer was not working and this stop the function from being called

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.