I have a field collection set up for fields that make up a slider, one of these fields is for the alignment of text in the slider & is hidden on output. I'm trying to get the value of this hidden field & use it to set a CSS class in the .tpl file, I've managed to do this but only in the .tpl file itself. If I understand it correctly it's best practise to get the value of this field in a preprocess function & expose it as a variable to the .tpl file, I'm unsure how to do this.
This is what I have written in the .tpl.php file, and it works, but from what I understand it's not best practise.
$key = key($items["entity"]["field_collection_item"]); $alignment = $items["entity"]["field_collection_item"][$key]["field_image"]["#object"]->field_alignment["und"]["value"];
I'm using the Drupal module fences to modify output so the code above is in the