Drupal6: In theme_preprocess_page (& $ vars), where does the $ vars come from? (How to manipulate breading)

I want to remove the breading when there is only one entry ("Main"). I'm in my topic theme_preprocess_page(&$vars)

. $ vars ['breadcrumb'] is available, but it's just HTML. It's a little awkward to work with. I would rather get it as an array of items in the palette list and do something like this:

if (count($breadcrumb) == 1) {


Where from $vars

? How can I override the source code that creates it?


source to share

1 answer

The $ vars array is passed between all preprocessing functions. In the case of _preprocess_page functions, most of the values ​​in $ vars are created in the template_preprocess_page (see http://api.drupal.org/api/function/template_preprocess_page/6 ). In this function, you will see:

  $variables['breadcrumb']        = theme('breadcrumb', drupal_get_breadcrumb());


Here drupal_get_breacrumb returns an array of palette items, which is then placed with the theme_breadcrumb () function (or its override).

The easiest way to get what you want is to override the theme_breadcrumb function. To do this, you take the original theme_breadcrumb function ( http://api.drupal.org/api/function/theme_breadcrumb/6 ), copy it into your template .php, replace 'theme' with the function name with your theme name and change the code. so it looks like this:

function THEMENAME_breadcrumb($breadcrumb) {
  if (count($breadcrumb) > 1) { // This was:  if (!empty($breadcrumb))
    return '<div class="breadcrumb">'. implode(' Β» ', $breadcrumb) .'</div>';


For a better understanding of Drupal overrides and preprocess functions, see About overriding valid output and Setting variables for use in a template (preprocessing functions) .



All Articles