Jump to content

Breadcrumbs (how-to), and what it says about the system


ryan
 Share

Recommended Posts

This should do the trick, if that's what you're looking for.

Note: not tested for syntax-errors, typed it directly in the commentarea.

:D

Awesome.

I was trying to figure out HOW it works (my PHP skills are at beginner level). And I understand it :)

".($parent == $page?" class='current'":"")."

So that's kinda like saying, if the page is the current page, put this class.

Link to comment
Share on other sites

Mine do!

If possible I like to surround it with bouncing ball, flashing arrows and a horde of Angels singing "We'll meet again"

Oh, and I tend not to have it linked .... :)

This is one for Bootstrap classes.

(I have left off the dancing chihuahuas)

<ul class='breadcrumb'>
<?php
    echo "<li><a href='{$pages->get("/")->url}'><i class='icon-home'></i></a>  </li>";
      foreach($page->parents as $parent) {
        echo "<li><a href='{$parent->url}'>{$parent->title}</a> <span class='divider'>/</span></li>";
    } 
    echo "<li class='active'>{$page->title}</li>";    
?>

</ul>
 
  • Like 2
Link to comment
Share on other sites

What breadcrumb in the world shows the page your already on?

I'm using Foundation4. Check out this little code snippet they have.

http://foundation.zurb.com/docs/components/breadcrumbs.html

I'm just learning to use ProcessWire, as I've been trolling here for a long time. I haven't actually used it for a site yet.

So I'm collecting all the snippets I need to use all my favorite elements and components from Foundation.

Link to comment
Share on other sites

I do have a habit on a couple of sites of having the current page added to the breadcrumb but without a link. It just feels more complete to me.

If it sounds odd, go back to the fairy tale and assume that the current page without a link is the spot you're standing on without dropping any breadcrumbs. "You are here, in case you didn't know and don't see the title in an obvious location on the page" can actually be relevant if you arrive at a page from search results for example, but I think it's more about personal tastes than anything else.

  • Like 1
Link to comment
Share on other sites

I look at it like a line of obedient hounds following a trail of tasty morsels.

When they get to where you are currently standing, they all sit there looking at you with big, expectant, eyes, waiting for you to drop something.

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Hi,

I show the breadcrumbs this way:

Parent >> Child >> Current-page

Parent and Child are links.

The Current-page is no link.

That works with this code:

<?php
foreach($page->parents() as $parent){
    echo "<a href='{$parent->url}'>{$parent->title}</a> > ";
}
// current page is no link
echo $page->title;

But when I go to the homepage (root), the breadcrumb shows:

Home

How can I develop that no breadcrumb (current-page) shows on the homepage?

I try it adding this code:

<?php
foreach($page->parents() as $parent){
echo "<a href='{$parent->url}'>{$parent->title}</a> > ";
}
$homepage = $pages->get("/");
if (!$homepage) {
  echo $page->title;
}

This don't work!

Link to comment
Share on other sites

<?php
foreach($page->parents() as $parent) {
    echo "<a href='{$parent->url}'>{$parent->title}</a> ";
}

That only works when current page has a parent actually.

For some page without a a physical parent. For instance, I implemented  a wordpress like archive url. That is the url is build with url segment,

like,  http://mydomain.com/2005/05/post-title

Home

    +---Blog

         +----post1

         +----post2

         +----post3

where 2005 and 05 are url segment but not a physical page, and you will only get Blog as the parent of all posts.

Instead, in more sense the breadcrumb should be like Home > 2005 > 05

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...