The template files for nodes and pages don't share any variable; that is true also for their preprocess and process functions.
Assuming we are talking of a node field implemented with the field API, then what follows applies:
The page preprocess and process functions have access to $variables['node']
which contains the node object, in the case the page is a node page
function mytheme_preprocess_page(&$variables) {
if (!empty($variables['node'])) {
$node = $variables['node'];
// …
}
}
The function to access the content of a entity field is field_get_items(), which returns its raw content
- The function to render a entity field is field_view_value()
The following code should work.
function mytheme_preprocess_page(&$variables) {
if (!empty($variables['node'])) {
$output = '';
$node = $variables['node'];
$items = field_get_items('node', $node, 'field name');
foreach ($items as $item) {
$field_output = field_view_value('node', $node, 'field name', $item);
$output .= render($field_output);
}
// Set $variables with the value you need.
}
}
Unfortunately, $variables['view_mode']
is passed only to the node preprocess/process functions; that value would be helpful to field_view_value()
, as its last parameter is the view mode.