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

moodle2.4 DIY 导航block的实例

May 25, 2016 pm 05:07 PM

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不带自定义功能,所以只能这样修改
Copy after login

                   

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

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Moondrop releases Block true wireless earbuds with low-latency game mode Moondrop releases Block true wireless earbuds with low-latency game mode Aug 10, 2024 pm 03:31 PM

Moondrop has released the Block true wireless earbuds for audio enthusiasts that sit comfortably in the outer ear. Unlike earbuds jammed into ear canals, the Block does not cause a plugged ear feeling or collect ear wax. The 13 mm driver is enclosed

Which navigation software is the football navigation voice package in? Which navigation software is the football navigation voice package in? Nov 09, 2022 pm 04:33 PM

The football navigation voice package in the "Amap Navigation" software is one of the navigation voice packages for the car version of the Amap map. The content is the navigation voice of Huang Jianxiang's football commentary version. Setting method: 1. Open the Amap software; 2. Click to enter the "More Tools" - "Navigation Voice" option; 3. Find "Huang Jianxiang Passionate Voice" and click "Download"; 4. On the pop-up page, click " Just use voice".

Baidu Maps App latest version 18.8.0 released, introducing traffic light radar function for the first time and adding real-time parking recommendation function Baidu Maps App latest version 18.8.0 released, introducing traffic light radar function for the first time and adding real-time parking recommendation function Aug 06, 2023 pm 06:05 PM

Both Android and iOS versions of Baidu Map App have released version 18.8.0, which introduces the traffic light radar function for the first time, leading the industry. According to the official introduction, after turning on the traffic light radar, it supports automatic detection of traffic lights while driving without having to enter a destination. Beidou High-Precision can position in real time. , 1 million+ traffic lights across the country automatically trigger green wave reminders. In addition, the new function also provides full silent navigation, making the map area more concise, key information clear at a glance, and no voice broadcast, allowing the driver to focus more on driving. Baidu Maps will launch a traffic light countdown function in October 2020, supporting real-time countdown prediction. Judgment, the navigation will automatically display the remaining seconds of the countdown when approaching a traffic light intersection, allowing users to always grasp the road conditions ahead. Traffic light countdown to December 31, 2022

What is the horizontal figure 8 on the navigation map? What is the horizontal figure 8 on the navigation map? Jun 27, 2023 am 11:43 AM

The horizontal figure 8 on the navigation map means haze, moderate is a yellow 8 warning signal, and severe is an orange 8 warning signal.

Amap launches upgraded version of driving ETA service: real-time analysis of current road conditions and more accurate estimated arrival time Amap launches upgraded version of driving ETA service: real-time analysis of current road conditions and more accurate estimated arrival time Apr 30, 2024 am 08:37 AM

According to news from this site on April 29, Amap officially announced the launch of an upgraded version of driving ETA (Note from this site: ETA is the estimated time of arrival, which refers to the estimated time it will take for the user to depart from the current moment and follow a given route to the destination. ) service, which aims to help users make more accurate route planning duration and traffic condition estimates, and assist users in making travel decisions. This map application is the latest upgraded Amap App. It introduces the "ultra-large-scale graph convolutional neural network model", which can better capture and learn traffic flow patterns, support urban road networks and highway systems, and can Accurately depict the spatiotemporal dynamic changes of traffic conditions. In addition, the new version of the map further integrates the iTransformer time series prediction model to support real-time analysis.

How to implement page jump and navigation in uniapp How to implement page jump and navigation in uniapp Oct 20, 2023 pm 02:07 PM

How to implement page jumps and navigation in uniapp. uniapp is a front-end framework that supports one-time coding and multi-end publishing. It is based on Vue.js. Developers can use uniapp to quickly develop mobile applications. In uniapp, implementing page jumps and navigation is a very common requirement. This article will introduce how to implement page jump and navigation in uniapp, and provide specific code examples. 1. Page jump Use the methods provided by uniapp to jump the page. uniapp provides a set of methods for implementation.

How to implement image browsing and thumbnail navigation through Vue? How to implement image browsing and thumbnail navigation through Vue? Aug 18, 2023 pm 02:51 PM

How to implement image browsing and thumbnail navigation through Vue? With the development of web applications, pictures play an increasingly important role in our daily lives. In many cases, we need to implement image browsing and thumbnail navigation functions. This article will introduce how to use the Vue framework to implement this function and provide code examples. In Vue, we can use the Vue plug-in to implement image browsing and thumbnail navigation functions. A popular plugin is vue-gallery, which provides a simple and easy-to-use interface

Use PHP and XML to implement web page navigation and menus Use PHP and XML to implement web page navigation and menus Aug 07, 2023 am 11:34 AM

Use PHP and XML to implement web page navigation and menus. Navigation and menus are common elements in web pages. They allow users to quickly find the information or functions they need. In web development, PHP and XML are often used to process and store navigation and menu data. This article will introduce how to use PHP and XML to implement web page navigation and menus, and provide relevant code examples. 1. Create an XML menu data file First, we need to create an XML file to store our menu data. The following is an example XML file that

See all articles