Skip to content

Instantly share code, notes, and snippets.

@isramv
Created February 19, 2016 00:04
Show Gist options
  • Select an option

  • Save isramv/a33a39ebf28dbe681fd3 to your computer and use it in GitHub Desktop.

Select an option

Save isramv/a33a39ebf28dbe681fd3 to your computer and use it in GitHub Desktop.
Template suggestion twig.
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function ixia_theme_suggestions_eck_entity_alter(array &$suggestions, array $vars, $hook) {
$entity = $vars['entity']['#slice'];
if(in_array('eck_entity__slice__resources_slice', $suggestions)) {
$template_suggestion_array = $entity->field_template_suggestion->getValue();
$template_lenght = count($template_suggestion_array);
if($template_lenght) {
$suggested_template = $template_suggestion_array[0]['value'];
$suggestion = $hook . '__ts__' .$suggested_template;
$suggestions []= $suggestion;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment