Federico Posted December 3, 2017 Share Posted December 3, 2017 Hello everyone, I am using a custom module with lister, which works just fine. The only thing that troubles me is how to display only one button at the top, instead of many duplicates that the lister module generates. here couple of snapshots to show it This is the button (green one on top right) on the header, which is the expected position. So the header looks perfect, whereas in the footer the module generates automatically two additional buttons (not wanted) the code to generates the lister and the button is all in ___execute() function. Here's the code $btnAddNew = $this->modules->get("InputfieldButton"); $btnAddNew->showInHeader(); $btnAddNew->href = "{$this->wire('config')->urls->admin}page/add/?parent_id=1101"; $btnAddNew->icon = 'plus-circle'; $btnAddNew->value = "Create new project code"; $btnAddNew->aclass = "classeAnchor"; $btnAddNew->addClass = "pw-modal"; $btnAddNew->id = "Test"; $pl = $this->modules->get("ProcessPageLister"); return $pl->execute() . $btnAddNew->render(); I've also tried this lister option: $pl->toggles = array('collapseFilters', 'noButtons'); // setting the deafult filter as collapsed, and no additional buttons but no luck for me. Then also I'm experiencing problem with the modal window for the button, as when I click the button the modal appear and abruptly redirects to add page section of PW, outside of the modal. But this is just a different issue.. Any help would be much appreciated Link to comment Share on other sites More sharing options...
dragan Posted December 3, 2017 Share Posted December 3, 2017 Can't you just configure your Lister with Disable "add new" page buttons? or set display: none on #ProcessListerResults + a button Link to comment Share on other sites More sharing options...
Federico Posted December 3, 2017 Author Share Posted December 3, 2017 Can you please suggest how to disable the AddNew page button in this case? like this? $pl->addNew = false; // ??? just an assumption, as this doesn't exists in lister options Link to comment Share on other sites More sharing options...
Robin S Posted December 6, 2017 Share Posted December 6, 2017 On 03/12/2017 at 10:22 PM, Federico said: So the header looks perfect, whereas in the footer the module generates automatically two additional buttons (not wanted) One button in the footer is expected - you are appending the rendered button to the Lister output after all. So there is just a single unexpected button being added. I think this is because your execute() method is called twice, once when the page is first rendered and once in an AJAX request from Lister. So you can make the rendering of the button conditional on it not being an AJAX request. $pl = $this->modules->get("ProcessPageLister"); $out = $pl->execute(); if(!$this->config->ajax) $out .= $btnAddNew->render(); return $out; 1 Link to comment Share on other sites More sharing options...
Federico Posted December 6, 2017 Author Share Posted December 6, 2017 Awesome, I didn't try this ajax conditional and the call made twice was the cause. I've changed only this to the above, to wrap all into one sigle $out $out .= $pl->execute(); // .= instead of simply = thank you very much 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