Jump to content


Photo

modules, process and the difference


  • Please log in to reply
5 replies to this topic

#1 MadeMyDay

MadeMyDay

    Sr. Member

  • Members
  • PipPipPipPip
  • 138 posts
  • 125

Posted 21 May 2012 - 09:13 AM

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?

#2 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 21 May 2012 - 10:08 PM

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.

#3 Soma

Soma

    Hero Member

  • Moderators
  • 3,183 posts
  • 1733

  • LocationSH, Switzerland

Posted 22 May 2012 - 03:09 AM

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...

@somartist | modules created | support me, flattr my work flattr.com


#4 MadeMyDay

MadeMyDay

    Sr. Member

  • Members
  • PipPipPipPip
  • 138 posts
  • 125

Posted 22 May 2012 - 03:28 AM

@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();
}

#5 Soma

Soma

    Hero Member

  • Moderators
  • 3,183 posts
  • 1733

  • LocationSH, Switzerland

Posted 22 May 2012 - 04:59 AM

Glad I could made your day! :P

@somartist | modules created | support me, flattr my work flattr.com


#6 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 22 May 2012 - 10:48 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users