If I use the following code in template.php and print $link
in node--post-esl-material.tpl.php, everything works fine; I get "hey baby."
function eslmooc_preprocess_node(&$vars, $hook) {
if ($vars['type'] == 'post_esl_material'){
$vars['link'] ='hey baby';
}
}
However, if I use the following code and print $link
in node--post-esl-material.tpl.php, it doesn't print anything.
function eslmooc_preprocess_node(&$vars, $hook) {
if ($vars['type'] == 'post_esl_material'){
$xyz = '';
if (empty($content['field_link']))
$xyz .= '';
else {
$xyz .= '<div class="link">';
$xyz .= '<h4>LINK</h4>';
$xyz .= '<div class="field_link">';
$xyz .= $content['field_link'];
$xyz .= '</div>';
$xyz .= '</div>';
}
$vars['link'] = $xyz;
}
}
I cannot get the PHP logic to work. Can anyone see a mistake within the code?