How to alter field values on a display page? I am trying to alter field values in a page display.  I can get the field values easily using field_get_items(), but depending on the values of other fields, I may need to manipulate the text and/or display based on some PHP logic in my template file.  I am trying to do it using either hook_page_alter() or hook_preprocess_HOOK().

I cannot get the text to be altered when the page is displayed using hook_page_alter() or hook_preprocess_HOOK().  I can confirm those 2 functions are working and that I can pull the values from the DB ($page['content']), but I cannot override the variable to set them.  For example:

function standard_submission_page_alter(&amp;$page) {
    $node = menu_get_object();
    $page['content']['system_main']['nodes'][$node-&gt;nid]['field_title_nickname']['#items'][0]['value'] = 'A new nickname title!';
}

function standard_submission_preprocess_page(&amp;$vars) {
    $vars['node']-&gt;field_title_nickname['und'][0]['value'] = 'A new nickname title 2x';
}


Any ideas on why my altering of this field_title_nickname text field value isn't being accepted and displayed?  It keeps reverting back to whatever is originally in the database.
If I need to manipulate the text and/or display based on some PHP logic, I would do it using hook_node_view() in a custom module, not in a template file.

function MYMODULE_node_view($node, $view_mode = 'full', $langcode = NULL) {
    if( $view_mode == 'full' ){
        if( some conditions here ){
            $node-&gt;content['field_title_nickname'] = array(
                '#markup' =&gt; '&lt;div&gt;A new nickname title 2x&lt;/div&gt;'
            );
        }
    }
}