I have a client who has just ONE page in the whole site where he wants the breadcrumb title to be different to the actual node title. Am I right in thinking your excellent module could do this for me?

Comments

ludo1960’s picture

Just use drupal_set_breadcrumb()

artatac’s picture

thanks - I have tracked the code down to common.inc and adapted the code as follows

unfortunatly it is ignoring my crude attempts!

 * Get the breadcrumb trail for the current page.
 */
function drupal_get_breadcrumb() {
$breadcrumb[] = l(t('Familybreadcrumbname'), 'Family');
  $breadcrumb = drupal_set_breadcrumb();

  if (is_null($breadcrumb)) {
  $breadcrumb[] = l(t('Familybreadcrumbname'), 'Family');
    $breadcrumb = menu_get_active_breadcrumb();
  }

  return $breadcrumb;
}
ludo1960’s picture

nope, just add php code to the one page that you want to change

artatac’s picture

Thanks _ I will look into it again

ludo1960’s picture

try:

<?php
  $links=array(l('Home','<front>'),l('yourlink','yourlink'));
  drupal_set_breadcrumb($links);
?>
artatac’s picture

THanks for your guidance .. and patience. Have created a custom templade just for relevant node > when I remove
print $breadcrumb;
the breadcrumb disappears so I know I have the right template! but when I then add the code above the breadcrumb remains empty
Should a print line be included?

MGN’s picture

Custom breadcrumbs could do this, but I agree with ludo1960 that this is not necessary for a single breadcrumb.

In your sites template.php file (in the theme directory) find the phptemplate_breadcrumb function. If you don't have a template.php file (or this function), you can add your own and modify it to check to see if you are on that special page where the breadcrumb gets modified.

In the example below, replace '/path/to/page' with the relative url to the page, and adjust the links to suit your needs (building on ludo1960's example)

Notice when you do it this way, you don't use drupal_set_breadcrumb - you just redefine the $breadcrumb array variable.

/**
 * Return a themed breadcrumb trail.
 *
 * @param $breadcrumb
 *   An array containing the breadcrumb links.
 * @return a string containing the breadcrumb output.
 */
function phptemplate_breadcrumb($breadcrumb) {
  if (url($_GET['q']) == '/path/to/page') {
    $breadcrumb = array( l('Home','<front>'), l('yourlink','yourlink') );
  }
  if (!empty($breadcrumb)) {
    return '<div class="breadcrumb">'. implode(' ⺠', $breadcrumb) .'</div>';
  }
}
artatac’s picture

that is terrific thanks - and working well - the final piece in the jigsaw is dealing with more than one (child page for which you want the custom breadcrumb eg:

if (url($_GET['q']) == '/tags-explained/tags-two') { becomes something like

if (url($_GET['q']) == '/tags-explained/tags-two' OR '/tags-explained/tags-three' or '/tags-explained/tags-four') {

or maybe

if (url($_GET['q']) ==(CONTAINS '/tags-explained/...') {

Thanks for your time - I am a Graphic designer (not a coder!) by trade let me know if I can return the favour to either of you

MGN’s picture

No problem. There are several ways to do this, but you might try

if (strpos(url($_GET['q']), '/tags-explained/') !== FALSE) {

This finds the position of the first occurrence of '/tags-explained/' in the url. If it doesn't occur, then the strpos returns false...

artatac’s picture

Works a treat - thanks SO MUCH!!

MGN’s picture

Title: just ONE page in the whole site » modify breadcrumb for just ONE page in the whole site
Status: Active » Fixed

Great! Closing this issue since the question has been answered. Also changing the title so its easier to find when searching do.

artatac’s picture

DOH!
having checked my real theme (based on pixtureRR) - rather than the Garland one I was using to test the idea, it HAS a template.php but no function phptemplate_breadcrumb. I tried just adding the above code but no luck.
I presume I am sheepishly asking for guidance to... just "redefine the $breadcrumb array variable."

ludo1960’s picture

Baah!!

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
  }

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.