При добавлении пользовательского блока Moodle показывает [[pluginname]] - PullRequest
0 голосов
/ 04 мая 2019

Я создаю пользовательский блок для Moodle, и при попытке добавить его на страницу отображается следующее:

How moodle name is shown

Вместоуказанное имя.

Файл version.php имеет следующие данные:

$plugin->component = 'block_userlist';
$plugin->version = 2019050316;
$plugin->requires = 2018120300;

И блок определяется как:

defined('MOODLE_INTERNAL') || die();

class block_userlist extends block_base {
    public function init() {
        $this->title = get_string('userlist', 'block_userlist');
    }
    // The PHP tag and the curly bracket for the class definition 
    // will only be closed after there is another function added in the next section.

    public function get_content() {
        global $DB;

        // if ($this->content !== null) {
        //   return $this->content;
        // }

        $user = $DB->get_record_sql('SELECT COUNT(*) as total_users FROM {user};');

        $this->content         =  new stdClass;
        $this->content->text  .= 'The content of our ';
        $this->content->text  .= html_writer::tag('span','UserList',['style'=>'color:red']);
        $this->content->text  .= ' block!';
        $this->content->footer = "Τotal Users: $user->total_users";
        return $this->content;
    }
}

Так как я могу задать другое имяот [[pluginame]]?

1 Ответ

2 голосов
/ 04 мая 2019

Вам необходимо добавить файл в свой плагин с именем lang / en / block_NAMEOFYOURPLUGIN.php и убедиться, что он имеет по крайней мере следующее:

<?php
$string['pluginname'] = 'The name of my plugin';

Вам понадобится очистить кеш сайта или ударномер версии вашего плагина, чтобы появилось имя.

...