Reputation: 10032
I am creating a custom block for moodle and when I try to add it into a page is shown as follows:
Instead of a specified name.
The version.php
file has these:
$plugin->component = 'block_userlist';
$plugin->version = 2019050316;
$plugin->requires = 2018120300;
And the block is defines as:
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;
}
}
So how can I set a name different from [[pluginame]]
?
Upvotes: 1
Views: 817
Reputation: 6317
You need to add a file within your plugin called lang/en/block_NAMEOFYOURPLUGIN.php and make sure it has at least the following:
<?php
$string['pluginname'] = 'The name of my plugin';
You will need to the purge the site caches or bump your plugin version number, in order for the name to appear.
Upvotes: 6