Saturday, February 13, 2010

How to create custom breadcrumb for node pages ?

Write this function on your template.php file in themes folder

function MYTHEME_preprocess_page(&$variables) {
if ($variables['node']->type == 'MYNODETYPE') {

$links = array();

// yet another link
$links[] = l('Some Other Link', 'SOMEOTHERLINK');

// lastly, overwrite the contents of the breadcrumbs variable in the page scope
$variables['breadcrumb'] = theme('breadcrumb', $links);
}
}


Example
function MYTHEME_preprocess_page(&$variables) {
if ($variables['node']->type == 'project') {

$links = array();

// yet another link
$links[] = l('Projects', 'projects');
$links[] = l($variables['node']->title, 'node/'.$variables['node']->nid);

// lastly, overwrite the contents of the breadcrumbs variable in the page scope
$variables['breadcrumb'] = theme('breadcrumb', $links);
}
}

No comments:

Post a Comment