pogidude Posted August 5, 2013 Posted August 5, 2013 Just figured out something today which I think is pretty cool (at least I thought so since I haven't found this in any docs), although I'm still trying to figure out how to make it work for my module. As an example, under admin/setup/template/, when you add the text "add" to your url - admin/setup/template/add - in ProcessTemplate, the executeAdd() method is called. When you type "edit" instead, the executeEdit() method is run instead. I'm just wondering how this works. I tried creating a similar method in my module - executeTest() with some dummy inputfields and I got a 404 error instead. I'm trying to add a "this is what's going to happen if you set this option" page - like what happens when you change templates in the page or when you remove a field from a template.
Wanze Posted August 5, 2013 Posted August 5, 2013 You can do this in ProcessModules. If no URL segment is given, ProcessWire executes the execute() method of your class. If you visit the module with an urlSegment, Pw executes the executeNameofurlsegment() method. Example: I used this in my Google Analytics module to load the statistics for the different sections with ajax: https://github.com/wanze/ProcessGoogleAnalytics/blob/master/ProcessGoogleAnalytics.module#L357 What does the code of your module look like? Do you extend Process? 2
pogidude Posted August 5, 2013 Author Posted August 5, 2013 The module does extend process https://github.com/ryannmicua/ProcessContentFlow/blob/master/ProcessContentFlow.module#L86 and that is the test urlsegment i'm trying. Just a thought though, would it matter if my process page doesn't exactly use 'admin' template? I have a different template in use and setting "admin" only as alternate template.
Wanze Posted August 5, 2013 Posted August 5, 2013 Did you enable urlSegments on your template? I'm not sure if it works with a template other than admin. The admin template has a select field called "process" where you define which Processmodule gets executed when visiting the page in the admin.
pogidude Posted August 5, 2013 Author Posted August 5, 2013 wow! works! weird though coz admin template has "allow page numbers" checked and not urlsegments. and yes, I had the "process" field on the custom admin template and it was working just fine - as long as you set alternate template to "admin" - except for the urlsegments thing. anyway, thanks for pointing me in the right direction 1
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