Jump to content

Multiple admin pages from ONE ProcessModule?


owzim
 Share

Recommended Posts

I want a settings page under /Admin/Setup for admins and an interface for the CMS user under Admin/ directly. Would I have to have two ProcessModules for that, or is it somehow possible to manage that logic in only one ProcessModule?

Thanks.

Link to comment
Share on other sites

Ha it's always the same with me. Right after I asked a question the light bulb pops up over my head.

I can simple have ONE ProcessModule, install it in /Admin/Setup and then create a new Page under /Admin and assign the same Process (edit/Process -> select) to it.

Or of course do that in the install method.

PW is awesome, have I mentioned that already?

Edit:

Then again, is it even wise to have two admin pages handled by one process? What I come across now is that since the two pages are aimed at different user roles I would have to manage both differently in one module. The handling of URLs is also nasty since I have to check under which parent the current process runs, for each executeSomething method.

Perhaps not such a good idea? The "need' stemmed from the idea to have both pages share methods and objects.

Link to comment
Share on other sites

Are you talking about the permission to access the module? Or different behavior based on roles?

The first one could be solved pretty simple like this:

    public static function getModuleInfo() {
        $permission = (wire('page')->parent->name == 'setup') ? 'role-a' : 'role-b';
        return array(
            'title' => 'Foo',
            'summary' => 'Bar',
            'permission' => $permission,
        );
    }

  • Like 2
Link to comment
Share on other sites

Thanks @apeisa and @Wanze for the suggestions.

Are you talking about the permission to access the module? Or different behavior based on roles?

The first one could be solved pretty simple like this:

    public static function getModuleInfo() {
        $permission = (wire('page')->parent->name == 'setup') ? 'role-a' : 'role-b';
        return array(
            'title' => 'Foo',
            'summary' => 'Bar',
            'permission' => $permission,
        );
    }

I know, thanks, but that's what I meant. I have to handle permissions manually, which I think is not that desirable.

I ended up creating a base class:

class MyModuleBaseProcess extends Process {
    // useful shared process methods here
}

And then have the both individual ProcessModules extend from it:

class ProcessMyModuleSetup extends MyModuleBaseProcess implements Module {
    // individual methods here
}

// and

class ProcessMyModuleUI extends MyModuleBaseProcess implements Module {
    // individual methods here
}
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

×
×
  • Create New...