检查预处理挂钩中节点的内容类型
我要在树枝模板上为特定的内容模板提供一系列变量。 在MYTHEME.theme我有: function MYTHEME_preprocess_node(&$variables) { if (isset($variables['node'])) { $mycustomblock = \Drupal::service('plugin.manager.block') ->createInstance('myblock', []); $variables['mycustomblock'] = $mycustomblock->build(); $headertext = \Drupal::service('plugin.manager.block') ->createInstance('headertext', [ 'text-align-submit' => 'right', 'uppercase-submit' => TRUE, 'header_size' => 'h4', 'header-size-submit' => 'h4', 'grid-size-submit' => 6, 'header-title' => 'This is a test', ] ); $variables['headertext'] = $headertext->build(); } } 这使我可以在{{ …