public function PanelizerNode::preprocessViewMode in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Plugin/PanelizerEntity/PanelizerNode.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerNode::preprocessViewMode()
- 8.4 src/Plugin/PanelizerEntity/PanelizerNode.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerNode::preprocessViewMode()
Preprocess the variables for the view mode template.
Parameters
array $variables: The variables to pass to the view mode template.
\Drupal\Core\Entity\EntityInterface $entity: The entity.
\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The Panels display used to render this entity.
string $view_mode: The view mode.
Overrides PanelizerEntityBase::preprocessViewMode
File
- src/
Plugin/ PanelizerEntity/ PanelizerNode.php, line 63
Class
- PanelizerNode
- Panelizer entity plugin for integrating with nodes.
Namespace
Drupal\panelizer\Plugin\PanelizerEntityCode
public function preprocessViewMode(array &$variables, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) {
parent::preprocessViewMode($variables, $entity, $panels_display, $view_mode);
/** @var \Drupal\node\NodeInterface $node */
$node = $entity;
// Add node specific CSS classes.
if ($node
->isPromoted()) {
$variables['attributes']['class'][] = 'node--promoted';
}
if ($node
->isSticky()) {
$variables['attributes']['class'][] = 'node--sticky';
}
if (!$node
->isPublished()) {
$variables['attributes']['class'][] = 'node--unpublished';
}
}