Filter does not add settings to $CFG

Filter does not add settings to $CFG

by Vladimir Ilyin -
Number of replies: 3

I develop filer.

In settins.php

$settings->add(new admin_setting_configtext('filter_name/imgbaseurl',
        new lang_string('imgbaseurl', 'filter_name'),
        new lang_string('imgbaseurl_desc', 'filter_name'), '', PARAM_NOTAGS));

I see the Settings page, can change the value, Filter is ON

but $CFG in filter() function does not contain this setting.

Why it can be?


Average of ratings: -
In reply to Vladimir Ilyin

Re: Filter does not add settings to $CFG

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Because you gave the setting name 'filter_name/imgbaseur'.

That means that it is not added to $CFG, which is loaded everywhere, which is good, it avoids bloat.

Instead, you need to load it where you need it, using

get_config('filter_name', 'imgbaseur');

In reply to Tim Hunt

Re: Filter does not add settings to $CFG

by Vladimir Ilyin -

Thank you very much!
It works.

But the documentation now is wrong.
I don't know whom I can ask to fix

https://docs.moodle.org/dev/Filters#Adding_a_global_settings_screen 

In reply to Vladimir Ilyin

Re: Filter does not add settings to $CFG

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It's a wiki. If you log in using your username and password from here, you can fix it yourself smile