Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Reversed breadcrumbs as Page Title

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1630 Views
  • pinkdigital
    Avatar
    Community Member
    7 Posts

    Reversed breadcrumbs as Page Title Link to this post

    Hi
    On some sites that we have built we reverse the breadcrumbs to make the page title... so if the breadcrumbs for a page where "Web Solutions » E-Commerce" in the page title we would have "E-Commerce | Web Solutions | Site Name etc"

    Is there a way to do this in SilverStripe without too much hassle.

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Reversed breadcrumbs as Page Title Link to this post

    You can just go on the code from the Breadcrumbs() function (located in sapphire/core/model/SiteTree.php). Copy this code to your Page class in mysite/code/Page.php
    and might be something like

    public function ReservedBreadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false) {
          $page = $this;
          $parts = array();
          $i = 0;
          while(
             $page
             && (!$maxDepth || sizeof($parts) < $maxDepth)
             && (!$stopAtPageType || $page->ClassName != $stopAtPageType)
          ) {
             if($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
                $parts[] = $page->Title;
             }
             $page = $page->Parent;
          }

          return implode(' | ', $parts);
       }

    Then just try $ReservedBreadcrumbs in the template

    1630 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.