Skip to content

Instantly share code, notes, and snippets.

@waako
Forked from jenitehan/get_paragraph.php
Last active April 27, 2016 15:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waako/22856e7f1c7125508fc0448217f7f1c7 to your computer and use it in GitHub Desktop.
Save waako/22856e7f1c7125508fc0448217f7f1c7 to your computer and use it in GitHub Desktop.
Get paragraph type of child field item
<?php
/**
* Implements hook_preprocess_HOOK for field--field-structured-content-section.html.twig
*/
function TEMPLATE_preprocess_field__field_structured_content_section(&$variables) {
$items = $variables['items'];
foreach ($items as &$item) {
$paragraph = $item['content']['#paragraph'];
$para_type = $paragraph->getType();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment