PhotoWebMax Posted December 3, 2014 Share Posted December 3, 2014 I have a new site with a hardwired topnav (uses a jQuery powered nav-sprite image) and a PW powered dynamic sideBar nav system. I am also using the basic Breadcrumbs system: <div class='breadcrumbs'><!-- breadcrumbs --> <?php // breadcrumbs are the current page's parents foreach($page->parents() as $item) { echo "<span><a href='$item->url'>$item->title</a></span> "; } // optionally output the current page as the last item echo "<span>$page->title</span> "; ?> </div><!-- end breadcrumbs --> This all works fine for the most part. I have a hidden container folder to contain all the generated sideBar links. What I don't like is that the hidden folder shows up in the Breadcrumbs navigation like so: Home > SideBarPages > Blog > Link One So, is there a way I can prevent the SideBarPages link from showing here? Thanks! Link to comment Share on other sites More sharing options...
kongondo Posted December 3, 2014 Share Posted December 3, 2014 div class='breadcrumbs'><!-- breadcrumbs --> <?php // breadcrumbs are the current page's parents foreach($page->parents() as $item) { //skip SideBarPages using id of the page. //You can also use $item->id=='1234' $item->title=='titleOfSideBarPages, $item->name, etc //using the ID, though less readable, is more foolproof if ($item=='1234') continue; echo "<span><a href='$item->url'>$item->title</a></span> "; } // optionally output the current page as the last item echo "<span>$page->title</span> "; ?> </div><!-- end breadcrumbs --> 5 Link to comment Share on other sites More sharing options...
horst Posted December 3, 2014 Share Posted December 3, 2014 If one want to exclude all hidden pages one may use: if ($item->isHidden()) continue; 3 Link to comment Share on other sites More sharing options...
PhotoWebMax Posted December 3, 2014 Author Share Posted December 3, 2014 Thanks Kongondo! That works perfectly. While I was at it I created a fresh includes file for the breadCrumbs code and then substituted that direct code from all my template files. Link to comment Share on other sites More sharing options...
neophron Posted September 27, 2019 Share Posted September 27, 2019 Hi there, five years later… ? Is it possible to hide a page in a breadcrumb depending on the template? Something like this (it's not working): <?php foreach($page->parents() as $item) { if ($item->('template=myTemplate')) continue; echo "<li><a href='$item->url'>$item->title</a></li> "; } echo "<li>$page->title</li>"; Link to comment Share on other sites More sharing options...
Robin S Posted September 27, 2019 Share Posted September 27, 2019 24 minutes ago, neophron said: Is it possible to hide a page in a breadcrumb depending on the template? $page->parents() can take a selector: foreach($page->parents('template!=myTemplate') as $item) { // ... 3 1 Link to comment Share on other sites More sharing options...
neophron Posted September 27, 2019 Share Posted September 27, 2019 14 minutes ago, Robin S said: $page->parents() can take a selector: foreach($page->parents('template!=myTemplate') as $item) { // ... Thanks! 1 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