Jump to content

Admin Custom Pages Module


diogo

Recommended Posts

Create custom admin pages easily without having to build a Process Module especially for that.

☞ This module makes it easy to create simple admin pages but you can also create them in much more powerfull way without the need of a module. Have a look at this post written by Bernhard Baumrock to know how it's done https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/

-------

I just updated the module, I kind of merged the two versions and now it works with both stable and dev versions of PW. Only difference is that with the stable version you still need to create the child pages and with dev version that is not needed.

The instructions are on Github. Enjoy :)

----

Download or clone from Github https://github.com/ocorreiododiogo/pw-admin-custom-pages

Module page is here 

http://modules.processwire.com/modules/process-admin-custom-pages/

Edited by adrian
Remove broken old module shortcut
  • Like 14
Link to comment
Share on other sites

Nice work diogo! Works like a charm!

Would it be possible to have custom code in the page using admin template somehow? That way we could use that parent page for some actions in situations where children pages wouldn't be needed?

Link to comment
Share on other sites

Nikola, try this one (needs the DEV branch of PW because it uses render($filename)).

Create a new template (can be named "customAdmin" for example) and put this on the template file:

<?php

$page->process = "ProcessAdminCustomPages2";

require($config->paths->adminTemplates . 'controller.php');

Create two fields and put them in the template:

  1. "render_file" (text field)
  2. "scripts_and_styles" (text area)

Now, if you create a page under admin and assign this template to it, you can specify a file to render the page.

To load scripts and styles add all the urls in each line (this is still a bit rough).

To add custom fields to the page, just create a new template without file, and specify "customAdmin" as the alternate template filename. Use this one instead of the "customAdmin". Add the "render_file" field to it and, optionally the "scripts_and_styles" field.

This version doesn't have configuration options

Edited by diogo
removed the attached file, as it was outdated
Link to comment
Share on other sites

@diogo -

this is working great.... in 20 minutes i made a product listing page for a client that displays a sortable, filterable table of all of their products, so they can find things without using the page tree...

-marc

  • Like 2
Link to comment
Share on other sites

Great to know Marc, but be aware that I don't consider this even nearly production ready. Did you try the first or the second version?

Link to comment
Share on other sites

Diogo,

Oh my, oh my! Just tested this. Awesome!!! OK, maybe am delusional but this is a game changer! I've been playing around with creating some simple modules but this makes me even lazier; all I need are template files! Hehe. I'll continue with learning how to do modules though ;)

I see "endless" possibilities with this module. Alternative pages view (I love the PW tree, but if an alternative view is needed...), product listings, galleries, etc, etc.

From my testing, it seems this renders the first child of the custom page, no? This means that to create other custom pages I'd need to repeat the process - create a new custom page that uses "Admin" template and assign the "ProcessAdminCustomPages" process then create a child page for this page... Would it be possible/easier to have multiple children of the one custom page (drop down menu) which will then render children pages with the custom content? This could be useful in some cases where there are quite a number of custom pages? Just thinking out loud here...Maybe the version 2 you've posted above would do allow such a scenario?

Many thanks for this! Watch out for examples of how I've been playing with this module! :)
Link to comment
Share on other sites

Thanks for the feedback kongondo. The second version doesn't need the child page at all. Sorry for the dispersion, but when I have more time I will wok to somehow merge the two ideas, or just decide for one. If you could test the second version, would be great! :)

Link to comment
Share on other sites

@diogo -

i'm using the 1st version, because i'm using 2.3 stable for this site; it's not live yet, but this will be a great thing to use, if you think it's ok for a live site;  I wasn't planning on using the dev for this site as it is going live soon...guess i should stick with the 1st version for now..?

Link to comment
Share on other sites

I think the second version is cleaner because it doesn't need the children. But you would have to ask Ryan if the dev version is stable for production :)

As for the first version, this is really new, I didn't test it a lot, and I probably won't keep the module with this format in the future. but if it's working well for you I don't think there will be a problem to use it in a live site. The core task of the module is actually very simple:

public function ___execute() {
    return $this->page->child->render();
}
Link to comment
Share on other sites

right, i'll just use it as is for now, since it is serving a purpose...on V2 of this site in 6 months i'll revisit and use the newer version, and also improve the page itself...

Link to comment
Share on other sites

ditto, beers are owed. this is such a great idea and comes in and solves something that i was planning on doing with a module, once i got my head around that, which could have been a while from now.

  • Like 1
Link to comment
Share on other sites

@Diogo,
 
I haven't had time to test the second version. Will do so sometime.
 
Meanwhile, I have been busy playing with the module and here's a taster...a CRUD system for:

  • a db external to PW (see video)
  • PW pages (attached screenshots)

Just fooling around at the moment. It is WIP as I learn the ropes of PW. In these examples I am using jTables. Will soon switch this to the great DataTables. Soma has a module of this one in the forums. Here I show how easy it is to implement using your module :)

 
Many thanks for your awesome module!

post-894-0-46292400-1367977420_thumb.png

  • Like 6
Link to comment
Share on other sites

Greetings Everyone.

I have also been playing around with data tables as the basis for a custom admin area. I have used JQuery DataTables, which kongondo refers to in his post above.

Managing data tables in ProcssWire, with the flexibility of ProcessWire's page and search capabilities makes this really exciting.

Links:

A dev example of 533 records with 58 fields managed with ProcessWire and Datatables: http://50.22.43.61/~wnpt/tennessee-crossroads-listings/

DataTables: http://www.datatables.net/

Note: At the moment, my example runs slowly!

Thans,

Matthew

Link to comment
Share on other sites

Sorry Soma, I'm not following. Can you give an example?

There is a process being executed, but the ProcessField is not there, obviously. I thought of giving instructions to add the ProcessField to templates instead of changing the admin.php file, but because that field is hidden it would make the process more difficult. You think it makes more sense to go that way instead?

Link to comment
Share on other sites

Maybe in this case nothing to worry about, but I find the Process modules a great thing also because it's a actual Class you can create execute functions and hook into them or load stuff from one module to another.

Now there's only one ProcessModuleAdminPages and one execute.

Link to comment
Share on other sites

Hm, I could think of a way of fixing that, but I really like that the module does this task in such a simple way, without changing too much on the system. I would also say that in this case is not such a problem to not be able too hook because these pages will be custom made and completely flexible.

Link to comment
Share on other sites

@Diogo,

Thanks for the update. How do you get around the issue of wanting your .css and .js to appear in a certain order? For instance, I wouldn't want my .css to be overriden by the Admin ones. I seem to recall an "append" method which will ensure your scripts are output in the order you want? Maybe I am not thinking this through clearly;).

Link to comment
Share on other sites

I confess I didn't think of this. I tried append instead of add, and it doesn't work. It makes sense since we are still appending the files before the others are also appended, because execute() comes in the admin.php on the core, and all the other files are appended in the admin template only later. From inside a Process module, I can't reach the head or the footer tags, and I didn't find the solution that you are talking in the forums...

Only solution that comes to my mind is to make a new module that would load automatically and hook to page render and allow me to add more script and style tags just after the last script and style tags. But this will require some studying, and won't be today :)

Anyone knows of a better solution?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...