Unable to transfer php logic from node--post-esl-material.tpl.php to template.php 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(&amp;$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(&amp;$vars, $hook) {
   if ($vars['type'] == 'post_esl_material'){
      $xyz = '';
      if (empty($content['field_link']))
         $xyz .= '';    
      else {
         $xyz .= '&lt;div class="link"&gt;';
          $xyz .= '&lt;h4&gt;LINK&lt;/h4&gt;';
           $xyz .= '&lt;div class="field_link"&gt;';
            $xyz .= $content['field_link']; 
           $xyz .= '&lt;/div&gt;';
         $xyz .= '&lt;/div&gt;';
      }
      $vars['link'] = $xyz;
   }
}


I cannot get the PHP logic to work. Can anyone see a mistake within the code?
I think that the problem is that $content is not defined there. You have it only inside the template file but not in the preprocess hook.