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

inteja created an issue. See original summary.

inteja’s picture

Anyone got any thoughts on this?

dsnopek’s picture

What 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!

inteja’s picture

Project: Layout Plugin (obsolete, use core's Layout Discovery) » Display Suite
Version: 8.x-1.x-dev » 8.x-2.3

Moved from Layout Plugin to Display Suite issues queue.

inteja’s picture

Issue summary: View changes
inteja’s picture

Does anyone have any experience with this sort of thing?

I could really do with a shove in the right direction.

inteja’s picture

I 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.

swentel’s picture

Version: 8.x-2.3 » 8.x-3.x-dev

Interesting, will check here what I can do expose those variables more, or document how to expose them.

  • swentel committed bc9d08df on 8.x-3.x
    Issue #2679979: document that original preprocess hooks are not called
    
swentel’s picture

Status: Active » Closed (works as designed)

The 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