I'm manually printing my node fields on its template (node--TYPE.tpl.php). Something like:
<div class="row">
<div class="press-year col-md-12">
<h2><?php print $year; ?></h2>
</div>
</div>
And my hook_preprocess_node() looks something like:
function MY_MODULE_preprocess_node(&$vars) {
switch ($vars['type']) {
case "my_type":
if (isset($vars["field_year"]["und"][0])) {
$vars["year"] = $vars["field_year"]["und"][0]["value"];
}
break;
}
}
The output is fine to all fields; however, when I view the node as administrator, no output is printed. I listed all the variables from the hook to see what was happening with the following code.
function MY_MODULE_preprocess_node(&$vars) {
var_dump($vars);
....
}
I'm getting all fields without the "UND" value, $vars["field_year"][0]["value"]
instead of $vars["field_year"]["und"][0]["value"]
.
Do you have any clue why this happens?
$vars["field_year"][0]["value"]
is what you get from Drupal 6.