[PHP] Identifier Config value
[PHP] Identifier Config value
Identifer: core.config
Location: acp_board.php
Parameters:
Explanation: If there is only one config value used by a extensions I would like the config value editable in acp board features instead of designing a whole page for editing this config value.
Location: acp_board.php
Parameters:
Explanation: If there is only one config value used by a extensions I would like the config value editable in acp board features instead of designing a whole page for editing this config value.
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [PHP] Identifier Config value
If you know some PHP I'd recommend trying to create the event yourself and then create a pull request for it.
Re: [PHP] Identifier Config value
Yes I know some php and I tried this day but it's really hard. As it was in the old days just add a line in core it's now a lot more.
I added a listener, edit services.yml and edit acp_board.php but still no go.
I know it's executing the listener but don't find back the vars.
Is there more documentation available?
I added a listener, edit services.yml and edit acp_board.php but still no go.
I know it's executing the listener but don't find back the vars.
Is there more documentation available?
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [PHP] Identifier Config value
You should not have to edit services.yml I would think. Why don't you submit what you've tried so far as a PR and we can take a look at it and help you with it.
Re: [PHP] Identifier Config value
Thanks Ex, I have it working.
Still one wish I have, can I define at which position the config_name is injected in the feature list?
Still one wish I have, can I define at which position the config_name is injected in the feature list?
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [PHP] Identifier Config value
What is your current code for it?
Re: [PHP] Identifier Config value
Hi Ex,
It's working now but don't know if it can be better:
In acp_board.php under featurelist:
In listener.php in ext
Thanks in advance
It's working now but don't know if it can be better:
In acp_board.php under featurelist:
Code: Select all
/**
* Event to add config
*
* @event core.acp_config_edit_add
* @since 3.1-A3
*/
global $phpbb_dispatcher;
$config_set_ext = $display_vars;
$vars = array('config_set_ext');
extract($phpbb_dispatcher->trigger_event('core.acp_config_edit_add', compact($vars)));
$display_vars = $config_set_ext;
Code: Select all
public function load_config_on_setup($event)
{
$config_set_ext = $event['config_set_ext'];
$config_set_vars = array_slice($config_set_ext['vars'], 0, 16, true);
$config_set_vars['inactive_users_days'] =
array(
'lang' => 'INACTIVE_USERS_DAYS',
'validate' => 'int',
'type' => 'number:0:99',
'explain' => true
);
$config_set_vars += array_slice($config_set_ext['vars'], 16, count($config_set_ext['vars']) - 1, true);
$event['config_set_ext'] = array('title' => $config_set_ext['title'], 'vars' => $config_set_vars);
}
- EXreaction
- Registered User
- Posts: 1555
- Joined: Sat Sep 10, 2005 2:15 am
Re: [PHP] Identifier Config value
That looks like a good start. There really isn't any need to rename the display_vars variable for the event.
Instead of putting the event within a specific mode, put the event after the switch ($mode) statement and send $mode and $display_vars to the listeners.
Using array_slice is about the only way to insert it at a specific location since the display vars is an associative array.
Instead of putting the event within a specific mode, put the event after the switch ($mode) statement and send $mode and $display_vars to the listeners.
Using array_slice is about the only way to insert it at a specific location since the display vars is an associative array.
Re: [PHP] Identifier Config value
Thanks Ex
acp_board
Listener:
acp_board
Code: Select all
/**
* Event to add config
*
* @event core.acp_config_edit_add
* @since 3.1-A3
*/
global $phpbb_dispatcher;
$vars = array('display_vars', 'mode');
extract($phpbb_dispatcher->trigger_event('core.acp_config_edit_add', compact($vars)));
Code: Select all
public function load_config_on_setup($event)
{
if ($event['mode'] == 'features')
{
$config_set_ext = $event['display_vars'];
$config_set_vars = array_slice($config_set_ext['vars'], 0, 16, true);
$config_set_vars['inactive_users_days'] =
array(
'lang' => 'INACTIVE_USERS_DAYS',
'validate' => 'int',
'type' => 'number:0:99',
'explain' => true
);
$config_set_vars += array_slice($config_set_ext['vars'], 16, count($config_set_ext['vars']) - 1, true);
$event['display_vars'] = array('title' => $config_set_ext['title'], 'vars' => $config_set_vars);
}
}