Zeka Posted June 5, 2016 Share Posted June 5, 2016 While editing any page in admin panel "Page tree" menu item is marked as active/current. I need to change active menu item for some of page types. I was trying to change parent by hooking after render, but Im not sure that i doing things right because i quite new to all these things about hooks. $page->addHookAfter("render", function(HookEvent $event) { $parent = wire("pages")->get(3062); $event->object->setParent($parent); }); But i got exception: Exception: Parent changes are disallowed on this page Is there another way to implement it? I would appreciate any suggestions? Link to comment Share on other sites More sharing options...
adrian Posted June 7, 2016 Share Posted June 7, 2016 I'm afraid I don't really know what you are trying to change - by the ""Page tree" menu item is marked as active/current", do you mean the breadcrumb trail? Perhaps a screenshot may help us understand your goal a bit better. 1 Link to comment Share on other sites More sharing options...
Zeka Posted July 24, 2016 Author Share Posted July 24, 2016 Hi @adrian I am sorry that i was not clear enough. For now i found out the answer to my question about changing active menu item. I'll describe it below so it will become more clear what I meant. I am using Admin Custom Pages for list some selection of pages. Under "Admin" page i created these pages: - Project ( This one plays role of separator and for it i choose "ProcessAdminCustomPages" as process, but leave blank selector of template. Not best solution, is there more right way? ) -- Entries ( Admin Custom Page / name: entries ) --- Edit ( ProcessPageEdit / Hidden Page / name: edit ) In template for "Entries" i use this code for links to edit page: $config->urls->admin."section/entries/edit/?id=".$page->id, So when i edit any page that listed on "Entries" page "Entries" menu item in sidebar menu marked as active/current. But now i have to modify breadcrumb to suit current page tree. Link to comment Share on other sites More sharing options...
adrian Posted July 24, 2016 Share Posted July 24, 2016 I think you are talking about changing the breadcrumbs in the PW admin - if so, then you can either hook after Process::breadcrumb, or hook before ProcessPageEdit::execute. Both have advantages and disadvantages. You can see how I did this here using the Process::breadcrumb hook. This works with both the default and Reno admin themes. https://github.com/adrianbj/AdminRestrictBranch/blob/master/AdminRestrictBranch.module#L121 Here is the the ProcessPageEdit::execute approach which doesn't work fully with Reno but is simpler in some ways: https://github.com/adrianbj/AdminRestrictBranch/blob/b5d27d1f118c34ba74d8548591a526513e68f48a/AdminRestrictBranch.module#L108 Hope I correctly understood what you wanted and that this helps. 2 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