Jump to content

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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/.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...