【问题标题】:Permanently show block in Moodle?在 Moodle 中永久显示块?
【发布时间】:2012-10-02 00:18:02
【问题描述】:

有没有办法在 Moodle 中永久显示一个块?我正在配置一个主题,我想知道是否有办法确保无论您在哪个页面上都可以看到一个块。

【问题讨论】:

    标签: moodle


    【解决方案1】:

    一种解决方案应该是添加一个新的块区域。
    在您的主题目录config.php文件中,修改布局选项并将新区域添加到所有使用的布局中:

    $THEME->layouts = array(
    'base' => array(
        'file' => 'admin.php',
        'regions' => array('your-region'),
        'defaultregion' => 'your-region',
    ),
    'standard' => array(
        'file' => 'admin.php',
        'regions' => array('your-region', 'side-post'),
        'defaultregion' => 'your-region',
    ),
    // The site home page.
    'frontpage' => array(
        'file' => 'general.php',
        'regions' => array('tools-menu', 'side-post'),
        'defaultregion' => 'tools-menu',
        'defaultregion' => 'tools-menu',
    ),
    'course' => array(
        'file' => 'general.php',
        'regions' => array('your-region'),
        'defaultregion' => 'your-region',
        'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true),
    ),
    etc...
    

    然后您编辑所有布局文件theme/your_theme/layout/*.php 并添加这一行您希望块出现的位置

    echo $OUTPUT->blocks_for_region('your-region');
    

    现在,您必须将所有页面类型的块添加到该区域,只需在您的数据库中执行此 sql:

    INSERT INTO `mdl_block_instances` (
    `id` ,
    `blockname` ,
    `parentcontextid` ,
    `showinsubcontexts` ,
    `pagetypepattern` ,
    `subpagepattern` ,
    `defaultregion` ,
    `defaultweight` ,
    `configdata`
    )
    VALUES ( NULL ,  'your_block_name',  '1',  '1',  '*',  NULL,  'your-region',  '0', NULL );
    

    【讨论】:

      猜你喜欢
      • 2022-06-15
      • 2019-03-26
      • 2022-09-24
      • 2012-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多