I'm trying to use a hook_page_alter() to change make the title of certain pages a link to another page.
This is the code I would like to alter.
function mashavumodule_page_alter(&$page) {
// get the user id of the patient
$user_id = $page['content']['system_main']['nodes'][$nid]['field_user_id']['#items'][0]['value'];
drupal_set_message(l("View Patient Profile", "user/{$user_id}" ));
}
Currently, I have the link outputting as a system message.
Also as a side note, if there is a more elegant way to get the value of the field_user_id, I'd love to know because typing
$page['content']['system_main']['nodes'][$nid]['field_user_id']['#items'][0]['value']
just doesn't seem right.