Jonathan Dart Posted December 17, 2013 Posted December 17, 2013 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
Jonathan Dart Posted December 17, 2013 Author Posted December 17, 2013 I found I could listen to ProcessPageList::execute and just overwrite the breadcrumbs, that should do the trick. 4
ryan Posted December 28, 2013 Posted December 28, 2013 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. 3
renobird Posted February 4, 2014 Posted February 4, 2014 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? 1
Jonathan Dart Posted February 6, 2014 Author Posted February 6, 2014 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); } } 3
ryan Posted February 8, 2014 Posted February 8, 2014 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. 4
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