通过修改navigationlib.php文件来达到自定义导航的目的。
//这里我改成 这样 后面有一个配置文件 读取 导航菜单的数据 //moodle/lib/navigationlib.php 1261行 或者搜索 "// Remove any empty root nodes" foreach ($this->rootnodes as $node) { // Dont remove the home node if ( $node->key !== 'courses' &&!in_array( $node->key , array(1,2,3,4,5,6,7,8,9)) ) { $node->remove(); } } //moodle/lib/navigationlib.php 1068行 或者搜索 "$this->rootnodes['users'] = $this->add(get_string('users'), null, self::TYPE_ROOTNODE, null, 'users');" // @添加几行代码 chmod( $CFG->dirroot . '/navigation.config.php' , 0777); $navigation_data = require( $CFG->dirroot . '/navigation.config.php'); foreach ( $navigation_data as $key => $value) { $this->rootnodes[$key] = $this->add( $value['text'] , null , self::TYPE_ROOTNODE , null , $key); foreach( $value['branch'] as $url){ $this->rootnodes[$key]->add_node( navigation_node::create( $url['text'], new moodle_url( $url['url']), self::NODETYPE_BRANCH, null, null, new pix_icon( $url['icon'] , '') )); } } //现在写个根目录下的配置文件 navigation.config.php <?php return array( 1 => array( 'text' => '学习中心', 'branch' => array( 0 => array( 'text' => '我的课程', 'url' => '/course/', 'icon' => 'i/db', ), 1 => array( 'text' => '成绩', 'url' => '/grades/', 'icon' => 'i/manual_item', ), 2 => array( 'text' =>'问答', 'url' =>'/quest/', 'icon' =>'i/feedback', ), ), ), 2 => array( 'text' => '账户管理', 'branch' => array( 0 => array( 'text' =>'账户', 'url' =>'/user/', 'icon' =>'i/lock', ), 1 => array( 'text' =>'订单', 'url' =>'/order/', 'icon' =>'i/payment', ), ), ), ); 再刷新 moodle页面,导航就被修改成自己需要的样子了。因为moodle不带自定义功能,所以只能这样修改
以上就是moodle2.4 DIY 导航block的实例的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
