php - 添加自定义块moodle时显示[[pluginname]]
问题描述
我正在为moodle创建一个自定义块,当我尝试将它添加到页面时显示如下:
而不是指定的名称。
该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]]
呢?
解决方案
您需要在插件中添加一个名为 lang/en/block_NAMEOFYOURPLUGIN.php 的文件,并确保它至少具有以下内容:
<?php
$string['pluginname'] = 'The name of my plugin';
您需要清除站点缓存或增加插件版本号,才能显示名称。
推荐阅读
- gatsby - fsevents.watch 错误运行 Gatsby hello-world 示例
- wpf - 将名称添加到特定样式控件 wpf
- sql - 将 char 转换为日期 - Hive
- linux - 修改时间以检查文件是否在过去 24 小时内被修改
- unity3d - 从 ARHumanBodyManger 获取 humanStencilTexture 的彩色像素
- javascript - 将 JS 对象值更改为键/值
- ibm-cloud - 如何在 ibm 云中为我的 kubernetes 集群生成 kubeconfig
- mongodb - 在猫鼬文档的子对象中填充内部属性
- spring-boot - 带有子列表的 Spring JPA 投影
- javascript - 盖茨比 + 内容丰富 + Netlify?