I'm stuck trying to pass variables from my theme_preprocess_field function to my template file. I want to have a variable for each of the fields I am printing out to my template.
I'm using the Paragraphs module in Drupal 7, so that might be throwing me off, but I feel like I'm really close. Here's a simple example:
Preprocess function in my template.php:
function merge_preprocess_field(&$variables) {
$element = $variables['element'];
if (isset($element['#field_name'])) {
if ($element['#field_name'] == 'field_title') {
$variables['test_title'] = $variables['items'][0]['#markup'];
}
}
}
The name of the template I am using is paragraphs-item--full-text.tpl.php
.
field_title
is the name of a field inside a paragraphs bundle called full-text
.
Everything that I have read so far indicates that I should be able to access the $variables['test_title']
variable in my template this way:
<?php print render($test_title); ?>
It doesn't print, even after clearing the cache. It's even showing up in the array when I krumo($variables);
. Am I missing something?