Spica Posted February 20, 2015 Share Posted February 20, 2015 Just moved to Processwire. I wonder, how to customize the lister of the core with a customadminpage. Id like to filter a pagelist by creator-id. Lister does that job perfect. But what I need is a custom admin page with the list, but no lister configuration/dropdowns. So the user just gets a predefined list of certain pages. So far I managed two basic things in the custom admin template $pl = $this->modules->get("ProcessPageList"); $pl->set('id',1001); echo $pl->execute(); processes me a tree, but I cant figure out how to filter for creationid $items = $pages->find("created_users_id=".$user->id ); $out = "<table width='100%'>"; $out .= "<thead>"; $out .= "<th>Title</th>"; $out .= "<th>Date Created</th>"; $out .= "<th>User</th>"; $out .= "<thead>"; $out .= "<tbody>"; if ($items != ""){ foreach ($items as $item) { $out .= "<tr>"; $out .= "<td><a href=". $config->urls->admin . "page/edit/?id=" . $item->id .">" .$item->title . "</a></td>"; // title $out .= "<td>" . date("F j, Y", $item->created) . "</td>"; // date created $out .= "<td>" . $item->createdUser->name. "</td>"; // user that created $out .= "</tr>"; } } else { // empty pageArray message $out = "<tr><td>No pages matching your criteria were found.</td></tr>"; } $out .= "</tbody>"; $out .= "</table>"; echo $out; This gives me nearly the list I want. But its generated with the pages object and a more static result list. What would you recommend, what is the best way to follow. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 20, 2015 Share Posted February 20, 2015 Ryan stated in the ListerPro Forum, that Lister is not intended to be used in "no-filters" mode, as it's overkill to load the thing for a "static" list. But you can use MarkupAdminDataTable.module, which is quite easy to use and generates the table you see in lister. You only need to fill it with data you'd define. These tables can be made sortable. For filters you would need to have custom javascript or some kind of form, to limit the displayed sites. Link to comment Share on other sites More sharing options...
Spica Posted February 20, 2015 Author Share Posted February 20, 2015 Thanx. Have already searched for MarkupAdminDataTable but could not find any good starting point. Is it documented somewhere? Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 20, 2015 Share Posted February 20, 2015 Nope, but it's kinda easy. // module context $table = $this->modules->get("MarkupAdminDataTable"); $table->headerRow( ["Title", "ID", "Created"] ); foreach($this->pages->find("some=pages") as $page){ $data = array( // Values with a sting key are converter to a link: title => link $page->title => $this->config->urls->admin."page/edit/?id=".$page->id, $page->id, $page->created ); $table->row($data); } // $table->footerRow( $someArray ); echo $table->render(); 4 Link to comment Share on other sites More sharing options...
Spica Posted February 21, 2015 Author Share Posted February 21, 2015 Great. To use it in a AdminTemplate I had to change it to $table = $modules->get("MarkupAdminDataTable"); $table->headerRow( ["Title", "ID", "Created", "User"] ); foreach($pages->find("created_users_id=".$user->id) as $page){ $data = array( // Values with a sting key are converter to a link: title => link $page->title => $config->urls->admin."page/edit/?id=".$page->id, $page->id, date("F j, Y", $page->created), $page->createdUser->name ); $table->row($data); } // $table->footerRow( $someArray ); echo $table->render(); and ad a missing $ Or would you recommend to use it as a modul over a custom admin template? And how to integrate the view/edit etc Buttons as in the tree view? 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 21, 2015 Share Posted February 21, 2015 There are different options for the table. By default all fields are entity encoded, but you could change this do insert own html code in the table fields. $table->setEncodeEntities(true|false); $table->setSortable(true|false); $table->setCaption(""); $table->setClass(""); // Add buttons after the table // same as for rows "label" => href $table->action($array); As for the best way to integrate this: Modules are more way more flexible and process modules are there for exactly that reason. Link to comment Share on other sites More sharing options...
Spica Posted February 23, 2015 Author Share Posted February 23, 2015 Did something like $table->action(array( 'New' => $this->config->urls->admin . 'page/add/?parent_id=1021', )); Which is ok for me now. Originaly I wondered how to get the edit/view/new/edit template Buttons after a click on a line. Isn't it a build in and reusable function. Would be good to know for the future. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 23, 2015 Share Posted February 23, 2015 It seems it's not a reusable function. The pagetree and lister variations do have completely different markup, only a class for the styling is the same. Link to comment Share on other sites More sharing options...
adrianmak Posted January 23, 2016 Share Posted January 23, 2016 How to set a column sortable in MarkupAdminDataTable instead of all columns ? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 23, 2016 Share Posted January 23, 2016 Hi adrianmak, here's a good read: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module It's not that don't want to fish and cook for you, but fishing your self will give you more experience. 4 Link to comment Share on other sites More sharing options...
KarlvonKarton Posted September 11, 2016 Share Posted September 11, 2016 On 20-2-2015 at 4:51 PM, LostKobrakai said: Nope, but it's kinda easy. // Values with a sting key are converter to a link: title => link $page->title => $this->config->urls->admin."page/edit/?id=".$page->id, I've tested this in the multi-language profile , but I got an error: "Warning: Illegal offset type" caused by $page->title. That is because 'title' is not a string, but an object in the multi-language profile. With following modification it works (if you want to see the default lang): $pg->title->getLanguageValue('default') => $this->config->urls->admin."page/edit/?id=".$pg->id, 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