General developer forum

Block configuration in externallib.php

Picture of Quentin Fombaron
Block configuration in externallib.php
Plugin developers

Hello everyone,

Can I have access to the block configuration in my externallib.php file ? Because I don't have access to $this->config, ,and get_config() method doesn't work, it is only for the general configuration.

I mean my block has different configuration values on each courses, and general values set by administrators (visible with  get_config('block_plugin_name')). So I need to access to values normally reachable with $this->config in block_plugin_name.php

Thank you smile

Average of ratings: -
Picture of Quentin Fombaron
Re: Block configuration in externallib.php
Plugin developers

I finally found a solution :

$coursecontext = context_course::instance($courseid);
$blockrecord = $DB->get_record('block_instances', array('blockname' => 'your_block_name',
'parentcontextid' => $coursecontext->id), '*', MUST_EXIST);
$blockinstance = block_instance('your_block_name', $blockrecord);

Average of ratings: Useful (1)