Jump to content

How to get module config data


Juergen
 Share

Recommended Posts

Hello,

I have tried to get the config data of the ProcessPageAdd module because I need the pages which are inside the ASM-Select for the 'Add new' shortcuts. This is what I have tried according to the docs:

$data = wire('modules')->getConfig('ProcessPageAdd');
print_r($data);

But the only output I get is 1(true). Is there something I am missing or is this the wrong way? Maybe someone can help me out.

Thanks

 

Link to comment
Share on other sites

Same result, but I have checked the database (table 'modules') and the data column is empty. So I am wondering where the shortcuts pages are stored? Inside the module file of this module you can find following lines:

$configData = $this->wire('modules')->getModuleConfigData($this); // because admin theme calls with noInit option
$shortcutSort = isset($configData['shortcutSort']) ? $configData['shortcutSort'] : array(); 

So there must be an index 'shortcutSort' inside the configuration array. Very strange?!?

Link to comment
Share on other sites

12 minutes ago, Juergen said:

Very strange?!?

@Juergen this is too much for monday! haha.

But you know, looking at the config page, this list probably generated on runtime because there is also no way to delete them on the config screen, I took a look at the source code and I THINK, it's happening here, so maybe you can call executeNavJSON?: 

https://github.com/processwire/processwire/blob/master/wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module#L151

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

3 minutes ago, elabx said:

maybe you can call executeNavJSON?:

Really complicated, but I will give this a try. I thought that it must be really simple to get the IDs of the pages in the shortcut navigation, but it isnt. Thanks for the tipp!!!

  • Like 1
Link to comment
Share on other sites

Now this works:

$module = wire('modules')->getModule('ProcessPageAdd');
$test = ($module->executeNavJSON());
return $test;

This gives me the following json-output:

{"url":"\/processwire\/processwire\/page\/add\/","label":"Modules","icon":"plus-circle","add":null,"list":[{"url":"?parent_id=1016&template_id=57","label":"Eine neue Leistung erstellen","icon":"plus-circle","parent_id":1016,"template_id":57},{"url":"?parent_id=1048&template_id=51","label":"Neuigkeit erstellen","icon":"plus-circle","parent_id":1048,"template_id":51},{"url":"bookmarks\/?role=0","label":"Lesezeichen","icon":"bookmark-o","className":"separator separator"}]}

And these are the pages I was looking for:

list":[
{"url":"?parent_id=1016&template_id=57","label":"Eine neue Leistung erstellen","icon":"plus-circle","parent_id":1016,"template_id":57},/n{"url":"?parent_id=1048&template_id=51","label":"Neuigkeit erstellen","icon":"plus-circle","parent_id":1048,"template_id":51}........

So I get:

parent_id: 1016, template_id:57 and

parent_id:1048, template_id:51

These are the 2 pages that I have in the shortcut menu and the IDs that I need?

Screenshot.thumb.png.f1e14e578317ea76b7182bea4db59f2f.png

So for the moment my new dashboard has the same functionality as the add-new navigation of PW, but a little more userfriendly than the small navigation in the left corner. New shortcut items can be added via the bookmark button, so every user can add his own favorites shortcuts to make his dashboard individually (if he has the rights of course ;-).

  • Like 3
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...