Melvin Suter Posted March 15, 2019 Share Posted March 15, 2019 Hi there I've got a problem: I want to create a group in the admin-menu for my modules pages. There are 3 Modules (DkConfig, DkTempalte and DkForms) which all have their own page. I've got a Core Module (DkCore) that has an install dependency to the other modules. I've tried to create the pages on my own inside the ___install() function and I've tried to do it over the pages key inside the module info. I just can't get it to work. Any tipps or ideas? Thanks & Regards, Melvin Link to comment Share on other sites More sharing options...
adrian Posted March 15, 2019 Share Posted March 15, 2019 Not much time to respond, but I bet the pages are created - check under Admin in the tree. It's probably a caching issue - do a modules refresh and logout and back in again. If you have Tracy installed, you can also just use the "Clear Session & Cookies" option in the PW Info panel. Hope that helps. PS I would definitely recommend using the module info pages approach - it handles everything for you, including uninstalling. Link to comment Share on other sites More sharing options...
Melvin Suter Posted March 15, 2019 Author Share Posted March 15, 2019 I tried clearing cache, etc. and I really don't think it has something to do with it. To clarify things, here some more infos and the 2 approaches: DkCore has this inside the getModuleInfo array: 'installs' => array("DkTemplate", "InputfieldDKEditor",'DkConfig','DkForms'), And all other Modules have this: 'requires' => ['DkCore','DkConfig'], First I tried it with pages inside the getModuleInfo like this (for every Module): 'page' => [ 'name' => 'dk-template', 'title' => 'DK Template', ], This does work, but generate a menu entry for each module. 1. Version: Then I tried this inside the DkCore: 'page' => [ 'name' => 'dk', 'title' => 'DK', ], and this in the child Modules: 'page' => [ 'name' => 'dk-template', 'title' => 'DK Template', 'parent' => '/dk/, ], This doesn't create any pages (or depending if I fidel around maybe creates a normal menu entry) 2. Version: Then I tried to delete the page entry fromt he getModuleInfo and add this to the DkCore Class: // Create Parent Page $newPageGroup = new Page; $newPageGroup->parent = $this->pages->get(2); $newPageGroup->template = 'admin'; $newPageGroup->title = 'DK'; $newPageGroup->name = 'dk'; $newPageGroup->process = 'ProcessList'; $newPageGroup->save(); // Create Template Page $newPage = new Page; $newPage->parent = $newPageGroup; $newPage->template = 'admin'; $newPage->title = 'Templates'; $newPage->name = 'templates'; $newPage->process = 'DkTemplate'; $newPage->save(); // Create Forms Page $newPage = new Page; $newPage->parent = $newPageGroup; $newPage->template = 'admin'; $newPage->title = 'Forms'; $newPage->name = 'forms'; $newPage->process = 'DkForms'; $newPage->save(); // Create Config Page $newPage = new Page; $newPage->parent = $newPageGroup; $newPage->template = 'admin'; $newPage->title = 'Config'; $newPage->name = 'config'; $newPage->process = 'DkConfig'; $newPage->save(); This does create the pages, but only the first one has a process set, the other ones don't. I tried to put the corresponding pages (tempalte etc.) inside the modules and let the DkCore just create the /dk/ page, but still, it doesn't work. I don't know if I'm doing something I shouldn't or if I do it the wrong way, but I really would love to find out. ? Thanks & Regards, Melvin Link to comment Share on other sites More sharing options...
Melvin Suter Posted March 15, 2019 Author Share Posted March 15, 2019 Correction: the first Version does only create /dk/ ! Link to comment Share on other sites More sharing options...
adrian Posted March 15, 2019 Share Posted March 15, 2019 I assume you have uninstalled and reinstalled your module? This is needed to create the admin pages. Sorry if this is obvious and you've already done it. Link to comment Share on other sites More sharing options...
Melvin Suter Posted March 15, 2019 Author Share Posted March 15, 2019 Just now, adrian said: I assume you have uninstalled and reinstalled your module? This is needed to create the admin pages. Sorry if this is obvious and you've already done it. Sometimes it is an obvious solution, but yes I've done it several times. And also: I tried to create the /dk/ page in ___install and the others via the page entry inside getModuleInfo. Only creates /dk/. Link to comment Share on other sites More sharing options...
Melvin Suter Posted March 15, 2019 Author Share Posted March 15, 2019 I think I might have found something, I used /dk/ instead of: $this->config->urls->admin.'dk/' I'm going to try this late. As a workaround: create the parent page on ___install() and the rest in the init() of the core (if not existing) Link to comment Share on other sites More sharing options...
adrian Posted March 15, 2019 Share Posted March 15, 2019 Looking at one of my Process Modules, I use: 'page' => array( 'name' => 'admin-actions', 'parent' => 'setup', 'title' => 'Admin Actions' ), The parent has no slashes and will be relative to admin. Link to comment Share on other sites More sharing options...
Robin S Posted March 15, 2019 Share Posted March 15, 2019 I think the DkCore module would need to create the parent page manually in the install() method (assuming DkCore is not a Process module). Then the other modules would specify the parent page by path as the "parent" within "page" within getModuleInfo(). But have you considered combining these three Process modules into a single Process module with several executeSomething() methods? Then you would create just a single page that uses this process and create a flyout menu for the other "execute" URL segments via the executeNavJSON() method. If you look at how some of the core Process modules that use flyout menus do this you'll get the gist of it. Link to comment Share on other sites More sharing options...
Melvin Suter Posted March 16, 2019 Author Share Posted March 16, 2019 So, I've got it to work. @adrian: that only works with setup, pages, access and modules, not with custom ones. The best way to do this looks like this. (As getModuleInfo pages doens't work.) DkCore.module public function ___install(){ // Create Parent Page $newPageGroup = new Page; $newPageGroup->parent = $this->pages->get(2); $newPageGroup->template = 'admin'; $newPageGroup->title = 'DK'; $newPageGroup->name = 'dk'; $newPageGroup->process = 'ProcessList'; $newPageGroup->save(); } And child modules (for example DkTemplate.module) public function ___install() { // Create Template Page $newPage = new Page; $newPage->parent = $this->pages->get($this->config->urls->admin.'dk/'); $newPage->template = 'admin'; $newPage->title = 'Templates'; $newPage->name = 'templates'; $newPage->process = 'DkTemplate'; $newPage->save(); } 1 Link to comment Share on other sites More sharing options...
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