When I view a node, my breadcrumb trail is not reflecting the correct path of the page (as I have defined it in the taxonomy heirarchy)... but when I view the term in taxonomy the breadcrumb appears to be working fine.

Any idea how I can get my nodes to display the same types of breadcrumbs that my taxonomy pages are displaying?

Ex:
the breadcrumb is is being displayed properly on this example, but how can I get these links to go to nodes and not terms?
http://sanluisrealtor.studiocreek.com/taxonomy/term/18

the full breadcrumb is not being displayed on this link:
http://sanluisrealtor.studiocreek.com/arroyo_grande_real_estate.html

The correct breadcrumb should be: Home » City » Arroyo Grande » Real Estate

The actual breadcrumb is: Home » Arroyo Grande Real Estate

Any ideas on this? Any help would be greatly appreciated...

Comments

venkat-rk’s picture

Read the taxonomy related tutorials on www.greenash.net.au to understand why you are having this problem.

You may either want to apply the patches there or use the pathauto module to get the kind of urls you want.

jenkins-1’s picture

Thanks for the reply ramdak - these tutorials have been very helpful and I have gotten the breadcrumb to look correct on the node pages... but how do I get the actual breadcrumb links to point to the main node pages... instead of the vocab pages?

When someone views "City >> New York >> Real Estate"
and they click on "New York" I would like them to go to my ..new_york.html page... not the vocab term "new york"

Know what I mean... I didn't see this question answered in the tutorial...

Thanks again!

matt@antinomia’s picture

Were you able to figure this out jenkins?

venkat-rk’s picture

The thing is that if 'New York' is a term in the vocabulary, clicking on it in the breadcrumb will take you only to the taxonomy term page (taxonomy/term/4 or whatever) or its aliased page (www.domain.com/city/newyork).

Since the term page will already list all postings tagged with 'New York', I don't really see a problem here- that is, no reason to link separately to newyork.html.

If what you are looking for is a way to alias your paths to end with .htm or .html, please look at this post:
http://drupal.org/node/42302

cfennell’s picture

Hi Jenkins,

You can achieve this by using the breadcrumb callback function within your template.php file. Here is how I have done this.

First, I call the breadcrumb callback function:

function phptemplate_breadcrumb($breadcrumb = NULL) {

I then do an array search for the key to a given value in the breadcrumb. When I find this key, I unset the item and then assign my own value to it like so:

if($bread_key = array_search ('<a href="/taxonomy/term/18">Taxonomy Item</a>', $breadcrumb)){
unset($breadcrumb[$bread_key]);
$breadcrumb[$bread_key]='<a href="/yournewlink" >New Link Here</a>';
}

Cheers,
-Chad

P.S. Make sure you're not calling the breadcrumb callback function inside another function w/in your template.php file.

gollyg’s picture

this is an interesting approach - i find the breadcrumbs a frustrating part of building a site using various modules. It would be great if there was a breadcrumbs section in admin that allowed you to define the dominant vocab/module for your breadcrumbs.

What i want to know is do you write out this code for each aliased page? And if so what is the advantage over using the path module to point a taxonomy page to another node?

cfennell’s picture

Hi,

As to you your first question, no I only alter the breadcrumb in a couple of cases. The reason I do this at all is that my site is primarily comprised of book pages and because I avoid relying upon using taxonomy terms to navigate the site. Without going into a lot of detail on the why's and the where's, I use this approach to insert a link to a book page where a link to a given taxonomy existed before. So, I don't re-alias on a page-to-page basis but on a taxonomy-by-taxonomy basis. I imagine that there may be an easier way to achieve this, but I'm not aware of it at the moment. And since I only need to change the breadcrumb in a couple of cases, I don't have the scalability issue that one might have on other sites.

As for the path module, I was under the impression that it only dealt with URLs, and did not tie into the breadcrumb system.

gollyg’s picture

yeah, i built a site using a book navigation system - great for the heirarchy...until you need to add some dynamic content. Then the breadcrumbing/navigation becomes a nightmare.

Im not sure about the path module - i think you can point a url of taxonomy/term/? to node/? and thus maintain your breadcrumbs. You still end up with ugly urls in the address bar though.

Thanks for your reply

wilgrace’s picture

Hi Chad,

Thanks for posting your solution - that's exactly what I need, but I can't seem to get it going. I have posted the following code (within its own function call) in a template.php file in my theme folder:

<?php
function phptemplate_breadcrumb($breadcrumb = NULL) {
if($bread_key = array_search ('<a href="/taxonomy/term/3">about us</a>', $breadcrumb)){
unset($breadcrumb[$bread_key]);
$breadcrumb[$bread_key]='<a href="/aboutus">about us</a>';
}
}
?>

For some reason, it just gets rid of the breadcrumb altogether - nothing shows on any of the pages. I'm using phptemplate in Drupal 4.6.

Any suggestions would be massively appreciated, as I really need to redirect the breadcrumb URLs.

Thanks

CrowChick’s picture

Having the same problem. This would be great if there were a fix!

averageyoungman’s picture

That function isn't returning anything to the system. What you see there is an override of the theme_breadcrumb() function in theme.inc, so it has to return something otherwise the entire feature will be disabled. So first, copy that function from theme.inc, place it in phptemplate.engine and replace "theme_" with "phptemplate_". Then do your transformations to the breadcrumb array before the following line:

return '<div class="breadcrumb">'. implode($breadcrumb, ' &raquo; ') .'</div>';

Then what gets returned will be what you want. You just have to make sure something gets returned, altered or otherwise. You can add just about anything you want there, and if you use the taxonomy_context.module you can get tons of information regarding the user's context on your site.

-- aym

CrowChick’s picture

Works like a charm!