Create settings.php file doesn't do anything

Create settings.php file doesn't do anything

by Quentin Fombaron -
Number of replies: 2

Hello,

I would like to create an admin configuration page for my block "Like", I've created a file settings.php in blocks/like. I've updated the version number and purged cache but the page doesn't appear in Site_Administration/Plugins/Blocks.


Here settings.php content but I think the file is not read at all

<?php
defined('MOODLE_INTERNAL') || die;

require_once($CFG->dirroot . '/blocks/like/lib.php');

if ($ADMIN->fulltree) {
try {
$settings->add(new admin_setting_configcheckbox(
'block_like/enable_likes',
get_string('enablelikes', 'block_like'),
'',
DEFAULT_LIKE_ENABLELIKES
));

$settings->add(new admin_setting_configcheckbox(
'block_like/enable_custom_like_pix',
get_string('enablecustompix', 'block_like'),
'',
DEFAULT_LIKE_ENABLECUSTOMPIX
));

$settings->add(new admin_setting_configstoredfile(
'block_like/levels_pix',
new lang_string('likepix', 'block_like'),
new lang_string('likepixdesc', 'block_like'),
'preset',
0,
['subdirs' => 0, 'maxfiles' => 20, 'accepted_types' => ['.png', '.jpg']]
));
} catch (coding_exception $e) {
echo 'Exception coding_exception -> blocks/like/settings.php) : ', $e->getMessage(), "\n";
}
}


Best regards,


Quentin F.

Average of ratings: -
In reply to Quentin Fombaron

Re: Create settings.php file doesn't do anything

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Did you add:

    function has_config() {
        return true;
    }

To your block's main class (in block_like.php)?

Unfortunately, for legacy reasons, settings.php doesn't get parsed if that isn't there.

Average of ratings: Useful (1)
In reply to Davo Smith

Re: Create settings.php file doesn't do anything

by Quentin Fombaron -

It was simple as that, thank you so much for your help smile