Node.php in Open Social 8.9
File
themes/socialblue/src/Plugin/Preprocess/Node.php
View source
<?php
namespace Drupal\socialblue\Plugin\Preprocess;
use Drupal\socialbase\Plugin\Preprocess\Node as NodeBase;
use Drupal\bootstrap\Utility\Element;
use Drupal\bootstrap\Utility\Variables;
class Node extends NodeBase {
protected function preprocessElement(Element $element, Variables $variables) {
parent::preprocessElement($element, $variables);
$node = $variables['node'];
$style = theme_get_setting('style');
$view_modes = [
'teaser',
'activity',
'activity_comment',
'featured',
'hero',
];
if ($style === 'sky' && in_array($variables['view_mode'], $view_modes)) {
if (!empty($variables['topic_type'])) {
$teaser_tag = $variables['topic_type'];
}
elseif (!empty($variables['event_type'])) {
$teaser_tag = $variables['event_type'];
}
else {
$teaser_tag = $node->type->entity
->label();
}
$variables['title_prefix']['teaser_tag'] = [
'#type' => 'inline_template',
'#template' => '<div class="teaser__tag">{{ teaser_tag }}</div>',
'#context' => [
'teaser_tag' => $teaser_tag,
],
];
}
}
}
Classes
Name |
Description |
Node |
Pre-processes variables for the "node" theme hook. |