Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a custom comment type and when I use the default comment.html.twig to render the comments then variables like new_indicator_timestamp and parent get rendered as expected. But if I switch to using a custom DS layout and copy across the relevant twig template code for those comment variables into my own custom layout then they don't work.
What do I need to do to ensure that the comment.module template_preprocess_comment() variables are available to my custom DS comment layout?
Comments
Comment #2
inteja CreditAttribution: inteja commentedAnyone got any thoughts on this?
Comment #3
dsnopekWhat module are you using to integrate Layout Plugin with comments? Is it Display Suite?
Layout Plugin itself just provides the registry of layouts. The data that's available to the template is up to the thing using Layout Plugin (for example, Display Suite or Panels). If you're using Display Suite, then this should be moved to that queue!
Comment #4
inteja CreditAttribution: inteja commentedMoved from Layout Plugin to Display Suite issues queue.
Comment #5
inteja CreditAttribution: inteja commentedComment #6
inteja CreditAttribution: inteja commentedDoes anyone have any experience with this sort of thing?
I could really do with a shove in the right direction.
Comment #7
inteja CreditAttribution: inteja commentedI would switch back just overriding the default comment.html.twig but I'm heavily reliant on the extra fields and custom fields that DS provides.
Comment #8
swentel CreditAttribution: swentel as a volunteer commentedInteresting, will check here what I can do expose those variables more, or document how to expose them.
Comment #10
swentel CreditAttribution: swentel as a volunteer commentedThe thing is, layouts have no clue about entities and don't call the preprocess_functions.
Since 9.5.x the #entity is available in the layout preprocess functions, so with custom code you could call the original preprocess hook and have those available in the template, see https://www.drupal.org/node/3278487