Created
February 19, 2016 00:04
-
-
Save isramv/a33a39ebf28dbe681fd3 to your computer and use it in GitHub Desktop.
Template suggestion twig.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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