찾다
php教程PHP源码moodle2.4 DIY 导航block的实例

moodle2.4 DIY 导航block的实例

通过修改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(
		&#39;text&#39; => &#39;学习中心&#39;,
		&#39;branch&#39; => array(
				0	=> array(
					&#39;text&#39;	=> &#39;我的课程&#39;,
					&#39;url&#39; 	=> &#39;/course/&#39;,
					&#39;icon&#39; 	=> &#39;i/db&#39;,
					),
				1 	=> array(
					&#39;text&#39;	=> &#39;成绩&#39;,
					&#39;url&#39;	=> &#39;/grades/&#39;,
					&#39;icon&#39;	=> &#39;i/manual_item&#39;,
					),
				2 	=> array(
					&#39;text&#39;	=>&#39;问答&#39;,
					&#39;url&#39;	=>&#39;/quest/&#39;,
					&#39;icon&#39;	=>&#39;i/feedback&#39;,
					),

		),
	),

	2 => array(
		&#39;text&#39; => &#39;账户管理&#39;,
		&#39;branch&#39; => array(
				0	=> array(
					&#39;text&#39;	=>&#39;账户&#39;,
					&#39;url&#39;	=>&#39;/user/&#39;,
					&#39;icon&#39;	=>&#39;i/lock&#39;,
				),

				1	=> array(
					&#39;text&#39;	=>&#39;订单&#39;,
					&#39;url&#39;	=>&#39;/order/&#39;,
					&#39;icon&#39;	=>&#39;i/payment&#39;,
				),
		),
	),
);
再刷新 moodle页面,导航就被修改成自己需要的样子了。因为moodle不带自定义功能,所以只能这样修改

                   

 以上就是moodle2.4 DIY 导航block的实例的内容,更多相关内容请关注PHP中文网(www.php.cn)!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.