I have defined a function to return an array and need to pass this array as a parameter to a template (node--contenttype.tpl.php).
function mymodule_preprocess_page(&$variables) {{
$variables['tdata'] = $myArray;
}
In node--contenttype.tpl.php
print $tdata;
I tried to call the variable $tdata, but the error shows
Notice: Undefined variable: tdata in include()...
The same error happens if I define a variable in template.php and call from node--contenttype.tpl.php.
Oops... I think I see your problem now.
You should be using hook_preprocess_node(), not hook_preprocess_page() if you want your variables to be available in your node template files.
Make sure you clear cache after you make the change too!
Let us know if that fixed your issue...