Title changed programmatically is not put into breadcrumbs I have 2 functions in template.php: The first attaches current page title to breadcrumbs; the second sets the title to 'Completion' when the user opens /scores/completion.

function lwt_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    if (!empty($breadcrumb)) {
        // Adding the title of the current page to the breadcrumb.
        $breadcrumb[] = drupal_get_title();

        // Provide a navigational heading to give context for breadcrumb links to
        // screen-reader users. Make the heading invisible with .element-invisible.
        $output = '&lt;h2 class="element-invisible"&gt;' . t('You are here') . '&lt;/h2&gt;';

        $output .= '&lt;div class="breadcrumb"&gt;' . implode(' » ', $breadcrumb) . '&lt;/div&gt;';
        return $output;
    }
}

function lwt_preprocess_page(&amp;$vars) {
      $path = drupal_get_path_alias();
      if ($path == 'scores/completion') {
            $vars['title'] = 'Completion';
      }
}


The breadcrumb is still scores. How do I fix it?
drupal_get_title() gets the title from a PHP static variable, which is different from the variable $variables['title'] passed to the template files. 

Your template hook would work if it uses the following code.

function lwt_preprocess_page(&amp;$vars) {
  $path = drupal_get_path_alias();
  if ($path == 'scores/completion') {
    // -1-
    $vars['title'] = t('Completion');
    drupal_set_title($vars['title']);
    // -1-
  }
}


What happens is the following:


lwt_preprocess_page() is invoked, and (through drupal_set_title()) sets the static variable containing the value returned from drupal_get_title().
template_process_page() is invoked, and it calls the theme function for the breadcrumbs; in your case that theme function is lwt_breadcrumb(), which calls drupal_get_title(), obtaining the same value you set in lwt_preprocess_page().


In lwt_preprocess_page() you could also replace the code between // -1- with the following one.

    unset($vars['title']);
    drupal_set_title(t('Completion'));


The reason also this code works is that template_process_page() first checks if $variables['title'] is set; if it is not set, it calls drupal_get_title().

  if (!isset($variables['title'])) {
    $variables['title'] = drupal_get_title();
  }


References


theme(), for the order in which theme template hooks are executed
drupal_static(), for understanding how the page title is stored in a static variable accessible to any function