KentBrockman Posted December 20, 2014 Share Posted December 20, 2014 Hey there! Is there any chance to place the create-buttons above the pages via a hook? Thanks for your great support. Link to comment Share on other sites More sharing options...
KentBrockman Posted January 16, 2015 Author Share Posted January 16, 2015 Sorry for pushing! Attached is an image to make clear what I ment in my previous post. Do you see any chance to place the button above the list? Thank you. Link to comment Share on other sites More sharing options...
Jan Romero Posted January 16, 2015 Share Posted January 16, 2015 There is probably a more robust way to do this, but, uh, I tried $this->addHookAfter('InputfieldPageTable::render', $this, 'PageTableRender'); public function PageTableRender($event) { $return = $event->return; $from = strrpos($return, "<div class='InputfieldPageTableButtons"); $to = strrpos($return, "</button></span></div>", $from); $buttons = substr($return, $from, $to-$from) . "</button></span></div>"; $event->return = $buttons . $event->return; } The Inputfield’s original render method puts the button html in the variable $btn, but I suppose there’s no way to just access that one. Another way to duplicate the button elements would be to just copy the code that generates them. 5 Link to comment Share on other sites More sharing options...
KentBrockman Posted January 16, 2015 Author Share Posted January 16, 2015 Such an good idea. Why didn't I think about it. Works fine in my case! Link to comment Share on other sites More sharing options...
KentBrockman Posted January 18, 2015 Author Share Posted January 18, 2015 After some more tests it seem's to be a bit buggy. By creating a new page via the button above the list the new page is generated and saved correctly, but this new page doesn't show up in the list. When I create a new page via the button under the list the page is generated correctly and a new (second) button appaers above the list. With this new button it is possible to create pages which show up in the list correctly. Link to comment Share on other sites More sharing options...
Jan Romero Posted January 18, 2015 Share Posted January 18, 2015 Indeed. Without really looking into it, the Javascript must depend on the position of the buttons. Try this to insert the buttons inside .InputfieldPageTableContainer: public function PageTableRender($event) { $return = $event->return; $from = strpos($return, "<div class='InputfieldPageTableButtons"); $to = strpos($return, "</button></span></div>", $from); $buttons = substr($return, $from, $to-$from) . "</button></span></div>"; $insertAt = strpos($return, "<table class='AdminDataTable AdminDataList'>"); $event->return = substr_replace($return, $buttons, $insertAt, 0); } Instead of this hackish string trickery, perhaps a better way to clone/move the buttons would be to use Javascript in the first place. I’m not sure how to best pull that off. Just append a script tag to $event->return? 1 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