Support » Plugins » Breadcrumb Hack for 1.01

  • Hi,
    I created a breadcrumb hack for the index.php. You can see it in action @ my blog. It works with WP 1.01.

    function get_breadcrumb($showRoot = true, $rootName = "Home") {
    global $p, $m, $author, $blogfilename, $s, $cat, $siteurl, $blogfilename, $tablecategories;
    echo "<div id=\"breadcrumb\">";
    if ($p || $m || $author || $s || $cat) {
    echo "$rootName > ";
    if ($p) {
    echo ""; the_title(); echo "";
    } else if ($m) {
    echo "Posts of ";
    if (strlen($m) == 6) {
    echo "" . date("F Y", strtotime($m."01")) . "";
    } else {
    echo "" . date("d.m.Y", strtotime($m)) . "";
    } else if ($author) {
    $user = get_userdata($author);
    echo "Posts by $user->user_nickname";
    } else if ($s) {
    echo "Search Results for $s";
    } else if ($cat) {
    echo "Category " . get_the_category_by_ID($cat) . "";
    } else if ($showRoot) {
    echo $rootName;
    echo "</div>\n";

    Post it here in the index.php:

    <div id="content">
    <?php get_breadcrumb(); ?>
    <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>

    And yes, I will post it to the wiki shortly.

Viewing 15 replies - 1 through 15 (of 23 total)
  • Ah, grasshoppah…we have trained you well.

    What’s this for? I went to your blog, but unfortunately I only read English. 😉

    I think it’s for the portion right under the header. It reads HOME and when you click on links, it updates according to what pages/posts you are looking at.

    Very nice!!!

    Yes, it’s the Navigation below the header and I even left it in English (for now at least) 🙂

    Nice, thank you! How can i change the separating caracter from “>” to “::” ?

    Great idea. I tried to get it to work and got this error though:
    Parse error: parse error in /home/debwire/public_html/photoblog/index.php on line 216

    Hy Lennart,
    I too got a parse error (on line 3 of my-hacks.php – line one is just ‘<?php’, then your code starts – using the updated code). Any idea why?

    I assume that a path breadcrumb normally stores data via a cookie, setting the ‘page history’ traversed or some such thing? Wouldn’t think that’d be too hard to do… hmmm…

    lennart: I guess we can agree to disagree. I was reading this discussion on SimpleBits and thought this quote was pertinent:

    Breadcrumb navigation is commonly used as a method for showing the user where they are within the structure of a site — and giving them an easy way of getting back.

    It is the last part, and giving them an easy way of getting back that this hack is missing.

    anatman: hmm, so I don’t. If you didn’t fix it yet copy your my-hacks.php to a file called my-hacks.phps and post the url. Then I can see the source.
    alexkingorg: then I aree with you (to disagree of course 🙂 ). We both seem have a valid point. Let’s carry then on to more relevant discussions…
    davidchait: no it wouldn’t be too hard. I would strore the information in a session variable, preferrably in an array. Maybe someone will just throw it together for you.

    nice, i’ll use that.
    dankeschön 😉
    grüße aus dtland.

    To piggyback on Alex’s notion of how a breadcrumb should work is like this: If I start on the main page, click on a category, then a post, I should get this (this is my interpretation of breadcrumbs)… Home > Category > Post Name. If I then click into January, I would expect to see this: Home > Category > Post Name > January. Now, depending on how many steps I want to track (5 seems like a good number), things can start to fall off the front of the list. There’s no need to track EVERYWHERE I’ve been, but having the last 4 or 5 places I was would be real handy.
    Home > Category > Post Name > January > Jan 20
    Category > Post Name > January > Jan 20 > Post Name
    Post Name > January > Jan 20 > Post Name > Home
    January > Jan 20 > Post Name > Home > Category
    You get the idea. To me that would be a breadcrumb to have….

    lennart: although the link you provided is interesting, a re-definition of what a breadcrumb is, is just that: a re-definition.
    Classic breadcrumb technology, which has been in effect more or less for around 8-10 years has prior art. A classic breadcrumb is just that, a trail starting with your first location and then following you wherever you go on a site, allowing you to then find your way back to where you have been.
    Fortunately we have things like prior art, which means you can’t just decide one day to change what a technology or concept is at your whim.
    Just saying.

    Jesuit. I agree with your definition of a breadcrumb. In fact, the best place I’ve seen it implemented in the manner we discussed can be found here: … far right, the Recently Visited list.
    lennart: I tried to ready every post in that thread, but got bored. The problem is that I don’t think most of the posters truely understood the intent behind breadcrumbs. Everyone wanted to treat it as a You Are Here (YAH) indicator. Which it isn’t. It’s a “How in the @#$% did I get HERE?”

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Breadcrumb Hack for 1.01’ is closed to new replies.