How can I exclude the $site() I call this the homepage then I want to exclude the next page and then every page after that I want to show everypage but $site();
For example. N
ow I have - If site() {nothing} else {show breadcrumb}
This returns nothing on the homepage
but on the other pages returns this. Home > Otherpage > OtherSubPage > AnotherPage.
What I want to do is.
Current Script Shows :
Home > Otherpage > OtherSubPage > AnotherPage.
New Script
If user visits Otherpage
Show Nothing
If user visits OtherSubpage
Otherpage > OtherSubPage
If user visits AnotherPage
Otherpage > OtherSubPage > Another Page
If you have a look at the breadcrumb method, you will see that it simply fetches the parents and then add the home page to it. So you just have to remove the homepage again.
public function breadcrumb() {
if(isset($this->cache['breadcrumb'])) return $this->cache['breadcrumb'];
// get all parents and flip the order
$crumb = $this->page()->parents()->flip();
// add the home page
$crumb->prepend($this->homePage()->uri(), $this->homePage());
// add the active page
$crumb->append($this->page()->uri(), $this->page());
return $this->cache['breadcrumb'] = $crumb;
}
If you are likely to use this more often (including future projects), Iβd create a custom site method for reuse:
site::$methods['crumbs'] = function($site) {
// get all parents and flip the order
$crumb = $site->page()->parents()->flip();
// add the active page
$crumb->append($site->page()->uri(), $site->page());
return $crumb;
};