Jump to content
Juergen

How to get module config data

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

 

Share this post


Link to post
Share on other sites

Maybe it's because the Array is printing as true? I don't see what could be going wrong! Have you tried:

print_r($data, true);

 

Share this post


Link to post
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?!?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Tracy's RequestInfo panel has all the details I think you are looking for:

image.thumb.png.c826733e101f6a95cafa97db70b7a570.png

  • Like 2

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...