OrganizedFellow Posted March 6, 2013 Share Posted March 6, 2013 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. 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 More sharing options...
Soma Posted March 6, 2013 Share Posted March 6, 2013 What breadcrumb in the world shows the page your already on? Link to comment Share on other sites More sharing options...
Joss Posted March 6, 2013 Share Posted March 6, 2013 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> 2 Link to comment Share on other sites More sharing options...
OrganizedFellow Posted March 6, 2013 Share Posted March 6, 2013 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 More sharing options...
Pete Posted March 7, 2013 Share Posted March 7, 2013 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. 1 Link to comment Share on other sites More sharing options...
Joss Posted March 7, 2013 Share Posted March 7, 2013 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. 2 Link to comment Share on other sites More sharing options...
tuxy Posted February 18, 2015 Share Posted February 18, 2015 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 More sharing options...
SteveB Posted February 19, 2015 Share Posted February 19, 2015 Try this: if (! $homepage->id) { echo $page->title; } Link to comment Share on other sites More sharing options...
diogo Posted February 19, 2015 Share Posted February 19, 2015 If ($page !== $homepage) 2 Link to comment Share on other sites More sharing options...
tuxy Posted February 23, 2015 Share Posted February 23, 2015 Thanks guys, if ($page !== $homepage) { .. } Works perfect 1 Link to comment Share on other sites More sharing options...
adrianmak Posted February 27, 2015 Share Posted February 27, 2015 <?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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now