Related nodes and custom breadcrumbs

21 August 2009 - 16:38

Sometimes, having an easy to use CMS like Drupal or Joomla is just one more excuse to keep on tweaking. Just now I added a related nodes block to the article and project pages. Let's say I write an article like this and I tag it drupal. A couple other articles on the same topic are shown in a block in the right column. Hard to do? I don't think so! Just use the views module an some view arguments, like so.

There's more stuff I changed in the last week or so. I completely changed the functionality of the breadcrumbs. I wanted them to reflect the structure I use for clean urls. But I wanted to use page titles instead of the url shorthand (and lowercase) terms. So I created a little snippet. Let's say I have an project with a fairly simple url like /projects/world-domination.

  1. first I fetch the url and system path
  2. then I breaks it up in into parts using the / as divider (so I have 3 parts: /, /projects and /projects/world-domination)
  3. for each part I check if the url is pointing to a valid page.
  4. for each valid target page I fetch the page title
  5. then I return all the breadcrumbs with valid links back to the theme
  6. If the clean url path wasn't found, the normal system breadcrumbs are used as a fallback mechanism

and... Presto! A simple breadcrumb bar for all the project nodes. Including "Home" and the current page's title. Off course I needed to find other solutions for Views, Taxonomy, System paths, etc. but that's a longer (and even more boring) story. I anyone's curious how I did it. I'll send them the code.

Comments

No teme

Polprav » 16 October 2009 - 20:04

Hello from Russia!
Can I quote a post in your blog with the link to you?

link

Bas » 17 October 2009 - 17:48
bas's picture

Hi Polprav,

I'd be happy to have the inbound link and read the quote on your website. So by all means, yes, post away!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <drupal6>, <javascript>, <php>. The supported tag styles are: <foo>, [foo].

More information about formatting options