Jump to content

Overriding ProcessPageList->setupBreadcrumbs()


Jonathan Dart
 Share

Recommended Posts

Hi Guys,

I'm trying to customize how breadcrumbs work in the backend for a site where admin users are jailed to a certain branch of the pages tree. I've figured out how to change the root page shown in the tree, but overriding the breadcrumbs doesn't seem to be possible without changing the ProcessPageList class. Any pointers?

Thanks,

Jonathan

Link to comment
Share on other sites

  • 2 weeks later...

There's also an API variable (on the admin side) called $breadcrumbs that you can either modify or replace. 

$breadcrumbs = new Breadcrumbs(); // start with a fresh breadcrumbs list if you want...
// $breadcrumbs = wire('breadcrumbs'); // ...or grab the existing copy
// then add breadcrumbs to it, here's one example: 
$breadcrumbs->add(new Breadcrumb($this->config->urls->admin . 'your/path/', "Your Label"));
wire('breadcrumbs', $breadcrumbs); // then set it back as an API variable
Note that breadcrumbs is just a type of WireArray, so everything from the cheatsheet applies in terms of modifying the contents of it. 
  • Like 3
Link to comment
Share on other sites

  • 1 month later...

Jonathan, 

I need to do the same thing - except for ProcessPageAdd.

Any chance you would be willing will to share how you worked this out?

Hi Renobird,

I assume you want to customize the breadcrumbs setup by ProcessPageAdd. I used a module for this particular project so it looks something like the below:

class YourModule extends WireData implements Module {
    ...
    public function init() {
        $this->addHookAfter('ProcessPageAdd::execute', $this, 'pageAddExecuteAfter');
    }
    public function pageAddExecuteAfter($event)    {
        if($this->fuel('page')->process != 'ProcessPageAdd') return;

        //build your new breadcrumbs
        $breadcrumbs = new Breadcrumbs();
        $breadcrumbs->add(...);
        //etc...

        $this->setFuel('breadcrumbs', null); // I forget if this is necessary, but it works.
        $this->setFuel('breadcrumbs', $breadcrumbs); 
    }
}
 
 
  • Like 3
Link to comment
Share on other sites

If you guys are using 2.3 or 2.4 you might prefer: $this->wire('key', 'value'); rather than $this->setFuel('key', 'value'); and $this->wire('key'); rather than $this->fuel('key'). The "fuel" terminology is meant mainly for internal use rather than public API. It'll work, but I think it makes code more complex than it needs to be, versus just using that single wire() function for everything. 

  • Like 4
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...