Jump to content

modules, process and the difference


Recommended Posts

Hello everybody,

I am evaluating the possibilities of customizing the admin. What I don't understand yet is the difference of a process module and a usual module. What I understand is that a process module is used as a single admin page which is able to get its actions via url segments. But how can I use a process module like the pagelister as a kind of widget in a yet to build admin dashboard? I would like to have some boxes on my dashboard like recent pages, other pages listings and also the page lister on the left. While I would implement the listings as custom modules (or one module with different settings) I am not sure how to use the page lister. Can I use the process module at all? Or do I have to build an own one by duplicating the process module as a starting point?

Link to comment
Share on other sites

Process is just an abstract module designed for extending. Its behavior is pretty simple in that it calls a method in the module matching the first URL segment. If there is a URL segment, it calls execute[urlSegment] in your Process module (if it exists), with the first character of the url segment in uppercase. For example, if your URL segment was "new", it would call executeNew(). If there is no URL segment, then it just calls execute(). So it is just a basic mapping of URL segments to methods with execute() being the default. I suppose this is kind of similar to code igniter except for the naming (with execute… being part of it) and PW doesn't pass any arguments to the execute() functions... rather you can retrieve them from $input->urlSegment($n) if you want them.

All of those execute[?] methods just return the content (markup) to be output. It is output directly in the #content div of the admin template. Unless the call was initiated by ajax, in which case just your output is sent (without the HTML document). Another differentiating point of Process modules is that if you have a .css or .js file in the same directory as the .module, with the same name as the module, it will be automatically loaded.

Lastly, if you edit any admin page, you'll see it lets you select what Process module to execute on that page. This logic can be applied beyond just the admin template if you want it to. It's a bit late here and I may be forgetting some things, so let me know if I'm not making sense or can provide any more info. But just wanted to reiterate that Process modules are very simple and there's not much to it.

  • Like 4
Link to comment
Share on other sites

Marc, you can see something interesting here http://processwire.c...e-nav-in-admin/

+Also Ryan still has to answer my question there ;)

You can load most modules and output them in your process module.

You can use Data Table Markup module or an submit button...

$dtable = $this->modules->get("MarkupAdminDataTable");
....
$out = $dtable->render();

Of course you can also output any code you like, or include a framework, a module of your own...

  • Like 2
Link to comment
Share on other sites

@Ryan: Brilliant! Shouldn't something like your text be in the documentation? :-)

@Soma: Perfect! That was what I was looking for:

public function execute(){

$pl = $this->modules->get("ProcessPageList");

$pl->set('id',1001); // or any other parent page

return $pl->execute();

}

Link to comment
Share on other sites

Shouldn't something like your text be in the documentation?

The audience for making Process modules is small enough that time for documentation is getting put towards broader scope stuff first. I think there might just be 4-5 of us that have an interest in making Process modules. :) But this will be in the documentation at some point, especially as interest for it grows.

  • Like 4
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
 Share

  • Recently Browsing   0 members

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