Skip to content

Instantly share code, notes, and snippets.

@normanlolx
Last active October 24, 2016 11:40
Show Gist options
  • Save normanlolx/ddc667c90c9c8e01efd3e0b70d5bf2cc to your computer and use it in GitHub Desktop.
Save normanlolx/ddc667c90c9c8e01efd3e0b70d5bf2cc to your computer and use it in GitHub Desktop.
Add class to paragraph
<?php
if ($paragraph->getType() == 'teaser') {
$alignment = 'left';
if ($paragraph->get('field_paragraphs_align')->first() !== NULL) {
$alignment = $paragraph->get('field_paragraphs_align')->first()->getString();
}
$variables['attributes']['class'][] = $alignment;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment