I tried to preprocess a title of the group in the result of the rendering of the view.


Actual: Group 1 title Item 1 Item 2 Item 3 Group 2 title Item 4 Item 5 Item 6

Expected: <span class="test">Group 1 title<span> Item 1 Item 2 Item 3 <span class="test">Group 2 title</span> Item 4 Item 5 Item 6

Here the similar question on the drupal.org https://www.drupal.org/project/drupal/issues/2950737.


If you want to change the template for the title of the group, why don't you override the template file views-view-grouping.tpl.php for Drupal 7, or views-view-grouping.html.twig for Drupal 8.

By standard Drupal templates names, overrides are also working with this one.

views-view-grouping--MACHINEVIEWNAME.tpl.php for a specific view

views-view-grouping--MACHINEVIEWNAME--MACHINEDISPLAYNAME.tpl.php for a specific display of a specific view.

Hope this can help you.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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