3

I have a custom CCK content type for blog posts and I’m using Views to display the posts in an archived list. I use two arguments—Node: Created year and Node: Created month—to generate the monthly and yearly archive pages, which allows me to build URLs like http://example.com/blog/2011 and http://example.com/blog/2011/08. This is pretty standard stuff and really easy to do with Views.

While the actual archive list pages are working just fine, the breadcrumbs that views generates are not. With the URL http://example.com/blog/2011/08, instead of creating this kind of trail (which seems correct):

Titles = Home > Blog  > 2011       > August  
URLs   = /      /blog   /blog/2011   /blog/2011/08  

… Views generates this incorrect breadcrumb trail:

Titles = Home > Blog  > 2011  > August  
URLs   = /      /blog   /blog   /blog/2011  

The URL generated for the year argument points to /blog rather than /blog/[yyyy], and the generated URL for the month argument only points to the year, not the month.

Going down one level (to http://example.com/blog/2011) creates a similar problem:

Titles = Home > Blog  > 2011
URLs   = /      /blog   /blog   

In both cases, none of the arguments' URLs are output correctly, while their titles are.

My settings for each of the arguments in Views are pretty standard: Month settings and Year settings. The path for the page display is just "blog".

What is causing this strange breadcrumb behavior and how can I fix it?

Thanks!

2 Answers 2

2
+50

The title and breadcrumb settings are often very confusing. Drupal usually does not display current page as part of breadcrumbs and that is how Views' settings work, too.

You need to keep in mind you're setting the title for the current page, but breadcrumb for the previous one in the hierarchy. That means: "what do I want to be added to breadcrumbs when this page is displayed".

Node: Created year
Title: Blog archive for %1
Breadcrumb: Blog

Node: Created month
Title: Blog archive for %2 %1
Breadcrumb: %1

This should fix the label-link matching for you. If you're using a theme that adds current page to breadcrumbs, or want current page's link in breadcrumbs anyway, let me know more about the theme you're using and if it's okay to have the current page's title there. Cheers!

5
  • Ooh. That's so close. I don't mind not having the current page title or link in the breadcrumb—I'm using a Zen subtheme and have that option turned off in the theme configuration already.
    – Andrew
    Commented Aug 12, 2011 at 17:03
  • However, I now have duplicate entries in my breadcrumbs: Home > Blog > Blog > 2011. Fortunately all the links are correct, but I can't figure out how to get rid of the extra "Blog" link.
    – Andrew
    Commented Aug 12, 2011 at 17:04
  • I wonder where the extra breadcrumb comes from, but it's not the views. Could you have added it there through a different module/theme for that particular path (blog)? It could be Custom breadcrumbs 2 or a PHP snippet somewhere.
    – Jan Tomka
    Commented Aug 13, 2011 at 0:04
  • 1
    Found it. It was Menu Trails, which I use to set breadcrumbs for nested menu items (like subpages of pages). Now I just need to find a way to fix the pages.
    – Andrew
    Commented Aug 13, 2011 at 21:50
  • Sweet! So is it all sorted at the views pages?
    – Jan Tomka
    Commented Aug 14, 2011 at 9:24
5

Check out the Custom Breadcrumbs module which has support for Views. Here is a quote about it (from the module's project page):

Custom Breadcrumbs 1:

Allows administrators to set up parametrized breadcrumb trails for any node type. This allows CCK-style node types to have "Home > User Blog > 2005 > January" style breadcrumbs on the node view page itself, synchronizing cleanly with custom views or pathauto aliases. Breadcrumb visibility can be customized via a php snippet.

Custom Breadcrumbs 2:

Many new features have been added including support for Views, Panels, Taxonomy vocabularies and terms, paths, and a simple API that allows contributed modules to enable custom breadcrumbs for module pages and theme templates. These are implemented using optional, independent submodules that depend on the main Custom Breadcrumbs module.

In addition to breadcrumb visibility, this version provides an option permitting PHP code snippets to be used in forming the breadcrumb titles and paths. Multiple languages are also supported.

1
  • I use that for my regular, non-Views pages. I've been playing with its Views support, but I can't get it to work well either. When I set custom breadcrumbs for my blog views page, both the month and the year links show up on both month and year views (when month shouldn't show up on the year view)
    – Andrew
    Commented Aug 8, 2011 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.