<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Brianlmerritt</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Brianlmerritt"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/Special:Contributions/Brianlmerritt"/>
	<updated>2026-04-14T09:53:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Using_the_Moodle_App_in_a_browser&amp;diff=56694</id>
		<title>Using the Moodle App in a browser</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Using_the_Moodle_App_in_a_browser&amp;diff=56694"/>
		<updated>2019-11-27T11:46:29Z</updated>

		<summary type="html">&lt;p&gt;Brianlmerritt: Update re issues when running the browser and it ignores the flags when the same browser is already running.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Chromium or Google Chrome browser are the recommended tools for Moodle Mobile development. But remember that if you are going to use functions provided by Phonegap you should use the Android SDK or iOs developer tools.&lt;br /&gt;
{{Moodle Mobile}}&lt;br /&gt;
{{Work in progress}}&lt;br /&gt;
&lt;br /&gt;
== Differences between Chromium and Google Chrome ==&lt;br /&gt;
&lt;br /&gt;
Google Chrome is the Chromium open source project built, packaged, and distributed by Google. We can say that Chromium is Google Chrome without the &amp;quot;Google&amp;quot; add-ons&lt;br /&gt;
&lt;br /&gt;
See https://code.google.com/p/chromium/wiki/ChromiumBrowserVsGoogleChrome for more information&lt;br /&gt;
&lt;br /&gt;
We recommend using Chromium instead Google Chrome&lt;br /&gt;
&lt;br /&gt;
== Advantages and disadvantages of using Chromium/Google Chrome ==&lt;br /&gt;
&lt;br /&gt;
Main advantages&lt;br /&gt;
* Quick development&lt;br /&gt;
* DOM inspector&lt;br /&gt;
* Network monitor&lt;br /&gt;
* Database (local storage) inspector&lt;br /&gt;
* Emulation options&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
* You can&#039;t test/develop using Phonegap APIs and Plugins&lt;br /&gt;
* If you use custom Phonegap code (including plugins) you will need to edit the mm.cordova.js for &amp;quot;emulate&amp;quot; those APIs in a browser&lt;br /&gt;
* You will always need to test in a real device and emulator prior to a production release&lt;br /&gt;
* You will need to verify that your CSS/layout works the same in an Android/iOs device&lt;br /&gt;
&lt;br /&gt;
== Installation == &lt;br /&gt;
&lt;br /&gt;
Install the “Chromium” browser just downloading it from https://download-chromium.appspot.com/&lt;br /&gt;
&lt;br /&gt;
In order to be able to access any domain via AJAX from the local file:/// protocol, you must run Chromium or Google Chrome in Unsafe mode adding this param:&lt;br /&gt;
&lt;br /&gt;
 --allow-file-access-from-files --disable-web-security --user-data-dir  --allow-running-insecure-content&lt;br /&gt;
&lt;br /&gt;
NOTE: Since Moodle 3.0 an onwards this shouldn&#039;t be necessary since the Web Service layer supports CORS requests apart from download assets such as your branded css.&lt;br /&gt;
&lt;br /&gt;
IMPORTANT: I strongly recommend you create a new link or application launch called &amp;quot;Chrome Unsafe&amp;quot; and use it only for testing the app. Better if you only use this browser for development. In Linux and possibly other operating systems the below arguments only work if you don&#039;t already have the same browser running without the args.  Hence if you use &amp;quot;google-chrome&amp;quot; as your normal browser then use &amp;quot;chromium-browser&amp;quot; for your cors free debugging and vice versa.&lt;br /&gt;
&lt;br /&gt;
How to open the browser:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;Path to chrome\chrome.exe&amp;quot; --allow-file-access-from-files --disable-web-security --user-data-dir  --allow-running-insecure-content&lt;br /&gt;
&lt;br /&gt;
or in Mac (you can use Automator for creating an app bundle)&lt;br /&gt;
&lt;br /&gt;
 open -a &amp;quot;Google Chrome&amp;quot; --args --allow-file-access-from-files --disable-web-security --user-data-dir  --allow-running-insecure-content&lt;br /&gt;
&lt;br /&gt;
or for Chromium&lt;br /&gt;
&lt;br /&gt;
 open -a /Applications/Chromium.app --args --allow-file-access-from-files --disable-web-security --user-data-dir  --allow-running-insecure-content&lt;br /&gt;
&lt;br /&gt;
In Mac you can use Automator for creating a launching app&lt;br /&gt;
&lt;br /&gt;
Now, you can open the application running:&lt;br /&gt;
 ionic serve --browser chromium &lt;br /&gt;
it should open a new tab in the current Chromium instance with the app, (remember that you have to open first the Chromium so it&#039;s started with all the additional arguments).&lt;br /&gt;
&lt;br /&gt;
If the ionic serve command open a new browser window, you should copy the URL and then paste it in the Chromium instance you opened using the command shell.&lt;br /&gt;
&lt;br /&gt;
== Sites for testing ==&lt;br /&gt;
&lt;br /&gt;
You can test the application using existing sites configured to have the Mobile services enabled.&lt;br /&gt;
&lt;br /&gt;
Real test site: If you type &amp;quot;student&amp;quot; or &amp;quot;teacher&amp;quot; in the &amp;quot;Site URL&amp;quot; field and then tap on &amp;quot;Add site&amp;quot; the app will connect to http://school.demo.moodle.net. This site is reset every hour so you may find unexpected behaviors&lt;br /&gt;
&lt;br /&gt;
== Browser Settings ==&lt;br /&gt;
[[{{ns:file}}:moodlemobile_developer.png|thumb|300px]]&lt;br /&gt;
You should develop always with the &amp;quot;Developer tools&amp;quot; panel open, you can open that panel with F12 (cmd + alt + i in Mac) or &amp;quot;Developer tools&amp;quot; in the Tools menu.&lt;br /&gt;
&lt;br /&gt;
[[{{ns:file}}:moodlemobile_options.png|left]]  Once opened, click on the wheel top-right corner to see the General options, you must Disable the cache there (this setting will work only if you have the Developer tools panel open)&lt;br /&gt;
&lt;br /&gt;
You can dock or undock into a separate window the developer panel using the &amp;quot;Dock&amp;quot; option just at the right of the settings wheel, you can move the developer panel to your right and resize the main browser window to emulate a Mobile device&lt;br /&gt;
&lt;br /&gt;
== Inspecting and changing the DOM ==&lt;br /&gt;
&lt;br /&gt;
Using the &amp;quot;Elements&amp;quot; option you can manipulate the DOM:&lt;br /&gt;
&lt;br /&gt;
* Add/modify style to elements&lt;br /&gt;
* Delete elements&lt;br /&gt;
* Move elements&lt;br /&gt;
* Inject HTML code&lt;br /&gt;
&lt;br /&gt;
You have complete information here: https://developer.chrome.com/devtools/index&lt;br /&gt;
&lt;br /&gt;
And also a free interactive course here: https://www.codeschool.com/courses/discover-devtools&lt;br /&gt;
&lt;br /&gt;
== Monitor XHR (ajax) requests ==&lt;br /&gt;
[[{{ns:file}}:moodlemobile_network.png|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
With the network panel you can check and filter all the HTTP request send from the app to your Moodle server.&lt;br /&gt;
&lt;br /&gt;
You can preserve the log in the navigation, filter by type of requests and also see complete information of all the requests made to the server where is hosted your Moodle installation.&lt;br /&gt;
&lt;br /&gt;
You can also identify with resources takes long to load&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Console, log and errors ==&lt;br /&gt;
[[{{ns:file}}:moodlemobile_log.png|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
The console panel is used for displaying the app log and errors, you can also configure Chrome for displaying there XHR requests&lt;br /&gt;
&lt;br /&gt;
In order to view the app log, you need first to enable Logging in the app (Options / Developers / Enable logging)&lt;br /&gt;
&lt;br /&gt;
You can use the console also for executing javascript commands, the console has access to the complete MM global object so you can call from there to core APIs functions of the app&lt;br /&gt;
&lt;br /&gt;
== Browsing the data base ==&lt;br /&gt;
[[{{ns:file}}:moodlemobile_localstorage.png|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
The Mobile app stores information in the local HTML5 IndexedDB&lt;br /&gt;
&lt;br /&gt;
You can inspect the local database in the Resources tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File system ==&lt;br /&gt;
[[{{ns:file}}:moodlemobile_filesystem.png|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
The first time you open the browser with the special flags you will see a couple of warnings, one asking you to accept to store information.&lt;br /&gt;
&lt;br /&gt;
You have to &amp;quot;Accept&amp;quot; that warning because it means that you will be able to emulate the device file system using the browser.&lt;br /&gt;
&lt;br /&gt;
For example, you will be able to download files to the browser storage (like the user profiles images, any resource in the course, etc..)&lt;br /&gt;
&lt;br /&gt;
You can browse the files stored in the application going to Settings &amp;gt; About and clicking the Filesystem root link.&lt;br /&gt;
&lt;br /&gt;
== Emulating devices ==&lt;br /&gt;
[[{{ns:file}}:moodlemobile_emulation.png|thumb|300px]]&lt;br /&gt;
&lt;br /&gt;
You can emulate mobile devices changing orientation, resolution, geo-location, touch events... It&#039;s not recommended to use de &amp;quot;Emulation Device&amp;quot; option because it just changes the user-agent and you could get some fails because of the jQuery Swipe library.&lt;br /&gt;
&lt;br /&gt;
The best option to test with the browser is just rescaling the window to get a new viewport size or use the screen settings in the &amp;quot;Emulation&amp;quot; screen.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
[https://developer.chrome.com/devtools/index Chrome Developer Tools help]&lt;br /&gt;
&lt;br /&gt;
[[Category: Mobile]]&lt;/div&gt;</summary>
		<author><name>Brianlmerritt</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Setting_up_your_development_environment_for_Moodle_Mobile_2_(Ionic_1)&amp;diff=50898</id>
		<title>Setting up your development environment for Moodle Mobile 2 (Ionic 1)</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Setting_up_your_development_environment_for_Moodle_Mobile_2_(Ionic_1)&amp;diff=50898"/>
		<updated>2016-09-13T08:44:58Z</updated>

		<summary type="html">&lt;p&gt;Brianlmerritt: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle Mobile}}&lt;br /&gt;
{{Work in progress}}&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The majority of your development work will be done using the browser. You will likely begin to use an emulator once you need to simulate a real mobile device.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install a browser for development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
I recommend Chromium browser (Google Chrome open source version) https://download-chromium.appspot.com/&lt;br /&gt;
Please, read Moodle_Mobile_development_using_Chrome_or_Chromium for more information&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install Node.js&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
http://nodejs.org for Mac users I recommend to install nodejs via macports.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT&#039;&#039;&#039;: Don&#039;t use node 4.0 or higher, there are incompatibilities with some of the packages we use. Please use v0.12.7 instead. The download directory for v0.12.7 is [https://nodejs.org/dist/v0.12.7/ here]&lt;br /&gt;
&lt;br /&gt;
&amp;quot;note&amp;quot;: if you also need later versions of node for other projects, use Node Version Manager aka &amp;quot;nvm&amp;quot; [https://github.com/creationix/nvm here]. Linux and OSX is supported, and the site has pointers to windows alternatives. Simply type:&lt;br /&gt;
   nvm install 0.12.15&lt;br /&gt;
   nvm use 0.12.15&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install ionic:&#039;&#039;&#039; &lt;br /&gt;
 npm cache clean&lt;br /&gt;
 npm install -g cordova ionic&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Clone the code base into a local directory in your computer.&#039;&#039;&#039;&lt;br /&gt;
 git clone https://github.com/moodlehq/moodlemobile2.git moodlemobiledirectory&lt;br /&gt;
 cd moodlemobiledirectory&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install the npm plugins dependencies&#039;&#039;&#039;&lt;br /&gt;
 npm install (This will install all the dependencies listed in package.json)&lt;br /&gt;
 sudo npm install -g bower (This will install bower in a folder that should be in the PATH)&lt;br /&gt;
 sudo npm install -g gulp (This will install gulp in a folder that should be in the PATH)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Add the iOS and Android platforms and install the required Cordova plugins&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Install the platforms. It&#039;s important to use these versions because newer versions are going to cause some problems with the plugins installed.&lt;br /&gt;
 ionic platform add android@4.1.1&lt;br /&gt;
 ionic platform add ios@3.9.1&lt;br /&gt;
&lt;br /&gt;
Run the following command to install the platforms and all the required Cordova plugins&lt;br /&gt;
 ionic state restore&lt;br /&gt;
&lt;br /&gt;
Please, note that if you are creating a custom app with a custom URL scheme, you should edit the /package.json file and specify there your custom URL_SCHEME (replacing the existing value) and your [https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md GCMPN SENDER_ID].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install bower globally and the required javascript files&#039;&#039;&#039;&lt;br /&gt;
 bower install (this will install all the libraries listed in bower.json)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Run gulp’s default tasks (in order to create the build files)&#039;&#039;&#039;&lt;br /&gt;
 gulp &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Open the app in the browser&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First start chromium via the command line using the custom parameters as is mentioned here: [[Moodle Mobile development using Chrome or Chromium]]&lt;br /&gt;
&lt;br /&gt;
and then, start the Ionic server:&lt;br /&gt;
&lt;br /&gt;
 ionic serve --browser chromium&lt;br /&gt;
&lt;br /&gt;
== Editor == &lt;br /&gt;
&lt;br /&gt;
There are several plugins for AngularJS and Ionic development available for common editors.&lt;br /&gt;
&lt;br /&gt;
Sublime 3 has plugins for [https://github.com/SublimeLinter/SublimeLinter-jscs jscs] (coding style) and [https://github.com/SublimeLinter/SublimeLinter-jshint jshint] (linter)&lt;br /&gt;
&lt;br /&gt;
Configuration files for jscs and jshint can be downloaded from https://github.com/angular/angular.js (.jscs.json and .jshint*)&lt;br /&gt;
&lt;br /&gt;
== Updating ionic and cordova ==&lt;br /&gt;
&lt;br /&gt;
 sudo npm update -g cordova&lt;br /&gt;
 sudo npm update -g ionic&lt;br /&gt;
&lt;br /&gt;
 ionic platform update android&lt;br /&gt;
 ionic platform update ios&lt;br /&gt;
&lt;br /&gt;
== Updating plugins ==&lt;br /&gt;
&lt;br /&gt;
 cordova plugin rm your_plugin_id&lt;br /&gt;
 cordova plugin add your_plugin_id&lt;br /&gt;
&lt;br /&gt;
== Building for Android and iOS ==&lt;br /&gt;
&lt;br /&gt;
Please see this guide to be able to build for Android and iOS using the command line:&lt;br /&gt;
&lt;br /&gt;
http://cordova.apache.org/docs/en/5.0.0/guide_platforms_index.md.html#Platform%20Guides&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Common errors when building&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* com.android.dex.DexException: Multiple dex files define XXX&lt;br /&gt;
Open the file &#039;&#039;platforms/android/build.gradle&#039;&#039; and add these code at the end:&lt;br /&gt;
&lt;br /&gt;
  configurations {&lt;br /&gt;
      all*.exclude group: &#039;com.android.support&#039;, module: &#039;support-v4&#039;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Could not resolve all dependencies for configuration &#039;:_debugCompile&#039;.&lt;br /&gt;
Open the Android SDK Manager and make sure you have installed: Android Support Repository, Android Support Library, Google Play Services and Google Repository.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Error: libsass bindings not found. Try reinstalling node-sass? ===&lt;br /&gt;
&lt;br /&gt;
Please read: http://fettblog.eu/gulp-and-node4-first-aid/, alternatively you must be sure that you installed Node v0.12&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
http://ionicframework.com/docs/cli/&lt;/div&gt;</summary>
		<author><name>Brianlmerritt</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Setting_up_your_development_environment_for_Moodle_Mobile_2_(Ionic_1)&amp;diff=50897</id>
		<title>Setting up your development environment for Moodle Mobile 2 (Ionic 1)</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Setting_up_your_development_environment_for_Moodle_Mobile_2_(Ionic_1)&amp;diff=50897"/>
		<updated>2016-09-13T08:32:50Z</updated>

		<summary type="html">&lt;p&gt;Brianlmerritt: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle Mobile}}&lt;br /&gt;
{{Work in progress}}&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The majority of your development work will be done using the browser. You will likely begin to use an emulator once you need to simulate a real mobile device.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install a browser for development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
I recommend Chromium browser (Google Chrome open source version) https://download-chromium.appspot.com/&lt;br /&gt;
Please, read Moodle_Mobile_development_using_Chrome_or_Chromium for more information&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install Node.js&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
http://nodejs.org for Mac users I recommend to install nodejs via macports.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT&#039;&#039;&#039;: Don&#039;t use node 4.0 or higher, there are incompatibilities with some of the packages we use. Please use v0.12.7 instead. The download directory for v0.12.7 is [https://nodejs.org/dist/v0.12.7/ here]&lt;br /&gt;
&lt;br /&gt;
&amp;quot;note&amp;quot;: if you also need later versions of node for other projects, use Node Version Manager aka &amp;quot;nvm&amp;quot; [https://github.com/creationix/nvm here]. Linux and OSX is supported, and the site has pointers to windows alternatives. Simply type:&lt;br /&gt;
   nvm install 0.12.25&lt;br /&gt;
   nvm use 0.12.25&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install ionic:&#039;&#039;&#039; &lt;br /&gt;
 npm cache clean&lt;br /&gt;
 npm install -g cordova ionic&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Clone the code base into a local directory in your computer.&#039;&#039;&#039;&lt;br /&gt;
 git clone https://github.com/moodlehq/moodlemobile2.git moodlemobiledirectory&lt;br /&gt;
 cd moodlemobiledirectory&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install the npm plugins dependencies&#039;&#039;&#039;&lt;br /&gt;
 npm install (This will install all the dependencies listed in package.json)&lt;br /&gt;
 sudo npm install -g bower (This will install bower in a folder that should be in the PATH)&lt;br /&gt;
 sudo npm install -g gulp (This will install gulp in a folder that should be in the PATH)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Add the iOS and Android platforms and install the required Cordova plugins&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Install the platforms. It&#039;s important to use these versions because newer versions are going to cause some problems with the plugins installed.&lt;br /&gt;
 ionic platform add android@4.1.1&lt;br /&gt;
 ionic platform add ios@3.9.1&lt;br /&gt;
&lt;br /&gt;
Run the following command to install the platforms and all the required Cordova plugins&lt;br /&gt;
 ionic state restore&lt;br /&gt;
&lt;br /&gt;
Please, note that if you are creating a custom app with a custom URL scheme, you should edit the /package.json file and specify there your custom URL_SCHEME (replacing the existing value) and your [https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md GCMPN SENDER_ID].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Install bower globally and the required javascript files&#039;&#039;&#039;&lt;br /&gt;
 bower install (this will install all the libraries listed in bower.json)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Run gulp’s default tasks (in order to create the build files)&#039;&#039;&#039;&lt;br /&gt;
 gulp &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Open the app in the browser&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First start chromium via the command line using the custom parameters as is mentioned here: [[Moodle Mobile development using Chrome or Chromium]]&lt;br /&gt;
&lt;br /&gt;
and then, start the Ionic server:&lt;br /&gt;
&lt;br /&gt;
 ionic serve --browser chromium&lt;br /&gt;
&lt;br /&gt;
== Editor == &lt;br /&gt;
&lt;br /&gt;
There are several plugins for AngularJS and Ionic development available for common editors.&lt;br /&gt;
&lt;br /&gt;
Sublime 3 has plugins for [https://github.com/SublimeLinter/SublimeLinter-jscs jscs] (coding style) and [https://github.com/SublimeLinter/SublimeLinter-jshint jshint] (linter)&lt;br /&gt;
&lt;br /&gt;
Configuration files for jscs and jshint can be downloaded from https://github.com/angular/angular.js (.jscs.json and .jshint*)&lt;br /&gt;
&lt;br /&gt;
== Updating ionic and cordova ==&lt;br /&gt;
&lt;br /&gt;
 sudo npm update -g cordova&lt;br /&gt;
 sudo npm update -g ionic&lt;br /&gt;
&lt;br /&gt;
 ionic platform update android&lt;br /&gt;
 ionic platform update ios&lt;br /&gt;
&lt;br /&gt;
== Updating plugins ==&lt;br /&gt;
&lt;br /&gt;
 cordova plugin rm your_plugin_id&lt;br /&gt;
 cordova plugin add your_plugin_id&lt;br /&gt;
&lt;br /&gt;
== Building for Android and iOS ==&lt;br /&gt;
&lt;br /&gt;
Please see this guide to be able to build for Android and iOS using the command line:&lt;br /&gt;
&lt;br /&gt;
http://cordova.apache.org/docs/en/5.0.0/guide_platforms_index.md.html#Platform%20Guides&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Common errors when building&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* com.android.dex.DexException: Multiple dex files define XXX&lt;br /&gt;
Open the file &#039;&#039;platforms/android/build.gradle&#039;&#039; and add these code at the end:&lt;br /&gt;
&lt;br /&gt;
  configurations {&lt;br /&gt;
      all*.exclude group: &#039;com.android.support&#039;, module: &#039;support-v4&#039;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Could not resolve all dependencies for configuration &#039;:_debugCompile&#039;.&lt;br /&gt;
Open the Android SDK Manager and make sure you have installed: Android Support Repository, Android Support Library, Google Play Services and Google Repository.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Error: libsass bindings not found. Try reinstalling node-sass? ===&lt;br /&gt;
&lt;br /&gt;
Please read: http://fettblog.eu/gulp-and-node4-first-aid/, alternatively you must be sure that you installed Node v0.12&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
http://ionicframework.com/docs/cli/&lt;/div&gt;</summary>
		<author><name>Brianlmerritt</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Using_images_in_a_theme&amp;diff=38853</id>
		<title>Using images in a theme</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Using_images_in_a_theme&amp;diff=38853"/>
		<updated>2013-04-11T10:10:33Z</updated>

		<summary type="html">&lt;p&gt;Brianlmerritt: /* Using your images within your layout files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Themes}}{{Moodle 2.0}}&lt;br /&gt;
==A little background==&lt;br /&gt;
Moodle 2.0 has introduced a new improved method of making use of images within its pages enabling theme designers to take full control over what images are being used and when possible ensures images are passed through Moodle&#039;s new performance caching system to obtain the best possible performance.&lt;br /&gt;
&lt;br /&gt;
$CFG-&amp;gt;themewww and custom pix in Moodle 1.9 and lower are gone from Moodle 2.0 and have been replaced by this new system.&lt;br /&gt;
&lt;br /&gt;
==Before we start==&lt;br /&gt;
&lt;br /&gt;
# Make sure you have a theme and images to work with, one that you have a backup of just in case.&lt;br /&gt;
# Take note of your theme&#039;s main layout file e.g. &#039;&#039;standard.php&#039;&#039;.&lt;br /&gt;
# Take note of your theme&#039;s main CSS file e.g. &#039;&#039;core.css&#039;&#039;.&lt;br /&gt;
# Turn on &#039;&#039;&#039;Theme designer mode&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==Image locations within Moodle==&lt;br /&gt;
&lt;br /&gt;
There are three main areas in which images are located - core, plugin and theme.&lt;br /&gt;
&lt;br /&gt;
Core images are used throughout Moodle and are stored in &#039;&#039;moodle/pix&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The pix directory contains the following subdirectories:&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;a&#039;&#039; - Icons that are not widely used&lt;br /&gt;
:&#039;&#039;c&#039;&#039; - Calendar-related icons&lt;br /&gt;
:&#039;&#039;f&#039;&#039; - File icons for different file types&lt;br /&gt;
:&#039;&#039;g&#039;&#039; - Default user icons and thumbnails&lt;br /&gt;
:&#039;&#039;i&#039;&#039; - General icons&lt;br /&gt;
:&#039;&#039;m&#039;&#039; - Currency symbols&lt;br /&gt;
:&#039;&#039;s&#039;&#039; - Smileys&lt;br /&gt;
:&#039;&#039;t&#039;&#039; - General icons&lt;br /&gt;
:&#039;&#039;u&#039;&#039; - User icons and thumbnails&lt;br /&gt;
:&#039;&#039;y&#039;&#039; - YUI icons&lt;br /&gt;
&lt;br /&gt;
Plugin images are used by plugins and are stored within the plugin&#039;s directory e.g. &#039;&#039;mod/forum/*&#039;&#039; or &#039;&#039;blocks/navigation/*&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Theme images are used in themes and are stored in the &#039;&#039;pix&#039;&#039; subdirectory of a theme.&lt;br /&gt;
&lt;br /&gt;
==Adding new images to your theme==&lt;br /&gt;
&lt;br /&gt;
To add new images to your theme, such as a background image or a logo, you should start by creating a pix directory within your themes directory.&lt;br /&gt;
&lt;br /&gt;
Lets assume you have two images, gradient.png and logo.jpg. Copy both files to your themes pix directory.&lt;br /&gt;
&lt;br /&gt;
The plan is to use gradient.png as the background image for your theme (in CSS) and use logo.jpg in the header (in your theme&#039;s layout file).&lt;br /&gt;
&lt;br /&gt;
===Using images within CSS===&lt;br /&gt;
&lt;br /&gt;
Moodle parses all CSS files. When theme designer mode is off, Moodle combines them into a handful of large CSS files that get cached and served. At the same time Moodle also looks at the CSS and replaces special syntax rules. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&#039;padding:10px;background-color:#f7f7f7;border:1px dashed #123456&#039;&amp;gt;&amp;lt;nowiki&amp;gt;[[pix:theme|&amp;lt;/nowiki&amp;gt;&amp;lt;span style=&#039;color:#336699;font-weight:bold;&#039;&amp;gt;&amp;lt;nowiki&amp;gt;path/to/image/&amp;lt;/nowiki&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&#039;color:#33993A;font-weight:bold;&#039;&amp;gt;imagename&amp;lt;/span&amp;gt;&amp;lt;nowiki&amp;gt;]]&amp;lt;/nowiki&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above pattern is looked for by Moodle and gets replaced with the correct image URL when found.&lt;br /&gt;
You should note the following things about this pattern when using your own images within CSS:&lt;br /&gt;
&lt;br /&gt;
# The bits in black don&#039;t change&lt;br /&gt;
# The bit in blue is the path to your image within the pix directory. It shouldn&#039;t start with a / but should end with one.&lt;br /&gt;
# The bit in green is the filename (&#039;&#039;&#039;no need to include the file extension&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
To use background.png as the background for our pages, add the following line of CSS to the themes core.css.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:theme|gradient]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before we look at how to use your own images within your themes layout files we should first look at how this changes if the image is in a sub directory.&lt;br /&gt;
&lt;br /&gt;
Lets assume gradient.png is located here: &#039;&#039;&#039;pix/myimages/gradients/gradient.png&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The CSS would need to be as follows:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:theme|myimages/gradients/gradient]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to refer to an image belonging to a plugin, you can do it like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body {background-image:url([[pix:quiz|icon]]);}&lt;br /&gt;
body {background-image:url([[pix:qtype_ddmarker|grid]]);}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That refers to mod/quiz/pix/icon.png/gif and question/type/ddmarker/pix/grid.png/gif respectively (or whatever icons you have put in your theme to override these).&lt;br /&gt;
&lt;br /&gt;
===Using your images within your layout files===&lt;br /&gt;
&lt;br /&gt;
To use logo.jpg within the header of the layout file, open the layout file e.g. general.php and find the correct spot to put your logo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;div id=&amp;quot;page-header&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Logo should go here --&amp;gt;&lt;br /&gt;
    &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
        echo $PAGE-&amp;gt;headingmenu;&lt;br /&gt;
    ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To achieve this I simply need to add the following line of code:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;img src=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;logo&#039;, &#039;theme&#039;); ?&amp;gt;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
As before, the image&#039;s file extension is not needed as Moodle finds it automatically.&lt;br /&gt;
&lt;br /&gt;
Combined the solution is very simple:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;div id=&amp;quot;page-header&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;logo&#039;, &#039;theme&#039;); ?&amp;gt;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
        echo $PAGE-&amp;gt;headingmenu;&lt;br /&gt;
    ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The only other thing to consider is how this example would look if logo.jpg was located in a subfolder e.g. &#039;&#039;&#039;pix/myimages/logos/logo.jpg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The code for this would be:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;img src=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;myimages/logos/logo&#039;, &#039;theme&#039;); ?&amp;gt;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note that&#039;theme&#039; above means the word theme, and not the name of your theme&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Overriding images in your theme==&lt;br /&gt;
&lt;br /&gt;
Overriding images within your theme can be an important part of creating and/or modifying themes.&lt;br /&gt;
&lt;br /&gt;
As mentioned, there are three main areas for images within Moodle, core, plugins, and themes. Obviously we won&#039;t be overriding theme images as we are in a theme and have full control over that already which just leaves core and plugin images that you may want to override.&lt;br /&gt;
&lt;br /&gt;
Within your theme create the following two directories:&lt;br /&gt;
; /pix_core/ : This is where your images to override core images will need to be.&lt;br /&gt;
; /pix_plugins/ : This is where images to override plugins will need to be.&lt;br /&gt;
&lt;br /&gt;
Next, copy the images that you wish to override into either the pix_core or pix_plugins directory. You need to replicate the directory structure that the images are located in.&lt;br /&gt;
&lt;br /&gt;
The following two examples illustrate how this works for both core and plugin images.&lt;br /&gt;
&lt;br /&gt;
===Overriding core images===&lt;br /&gt;
For this example I am going to override the following two images:&lt;br /&gt;
# &#039;&#039;&#039;moodle/pix/help.gif&#039;&#039;&#039; This image is used for all help image icons and is shown throughout Moodle.&lt;br /&gt;
# &#039;&#039;&#039;moodle/pix/i/info.gif&#039;&#039;&#039; This image is used in several places, most notably the front page if the combo list is being displayed.&lt;br /&gt;
&lt;br /&gt;
So first up help.gif. This is the most basic example of overriding an image. Because the image is directly within Moodle&#039;s pix directory we can simply place our new help image into our themes pix_core directory. There&#039;s nothing more to it!&lt;br /&gt;
&lt;br /&gt;
The second example if not really any more difficult. Because the image is located within the subdirectory &#039;&#039;&#039;i&#039;&#039;&#039; we must create a sub directory within our pix_core directory into which we will copy our new help image. That is, the image ends up at &#039;&#039;&#039;/pix_core/i/info.png&#039;&#039;&#039; inside your theme folder. And again done!&lt;br /&gt;
&lt;br /&gt;
You should also note that, as with any other image in Moodle, the extension doesn&#039;t matter. If you want to replace help.gif with a help.png you can just put the png into the correct directory. As long as the filename is the same Moodle will find it.&lt;br /&gt;
&lt;br /&gt;
===Overriding plugin images===&lt;br /&gt;
This is a little bit more difficult than overriding core images, but not too much so. For this example, let&#039;s say I want to override the following two plugin images:&lt;br /&gt;
# &#039;&#039;&#039;moodle/mod/forum/icon.gif&#039;&#039;&#039; This is the icon that is used everywhere for the forum.&lt;br /&gt;
# &#039;&#039;&#039;moodle/blocks/customblock/activate.png&#039;&#039;&#039; This is an icon in a custom block I have installed.&lt;br /&gt;
&lt;br /&gt;
First up, the forum icon. Just as with core images, we need to put the image in the correct directory structure. In this case it is going to be within our theme&#039;s pix_plugins directory.&lt;br /&gt;
&lt;br /&gt;
Here we need to create the directory structure between &#039;&#039;&#039;/mod/&#039;&#039;&#039; and the image, so we need the following structure &#039;&#039;&#039;/pix_plugins/mod/forum/&#039;&#039;&#039; and into the final forum directory we put our replacement image.&lt;br /&gt;
&lt;br /&gt;
The second example is done in exactly the same way, but with the blocks path. We simply need to put our replacement image in &#039;&#039;&#039;/pix_plugins/blocks/customblock/&#039;&#039;&#039; and it will automatically be overridden.&lt;br /&gt;
&lt;br /&gt;
When looking for an overriding image the following path is used.&lt;br /&gt;
&lt;br /&gt;
# theme (static)&lt;br /&gt;
# themename =&amp;gt; mytheme&lt;br /&gt;
# area =&amp;gt; pix_plugins for plugin images, pix_core for core images, pix for theme images.&lt;br /&gt;
# plugin type =&amp;gt; booktool for the book tool sub plugin for example.&lt;br /&gt;
# plugin name =&amp;gt; print for the name of the sub plugin.&lt;br /&gt;
# file name =&amp;gt; book for the name of the image.&lt;br /&gt;
&lt;br /&gt;
It then searches for the image with the following extensions gif, png, jpg, jpeg in that order.&lt;br /&gt;
&lt;br /&gt;
So you end up with:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/theme/themename/area/plugintype/pluginname/filename.gif&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example: Silkicons theme==&lt;br /&gt;
As an example of how this all looks when done I have attached a screen shot of a theme I quickly created using the Silk icon set created by Mark James available at [http://famfamfam.com/lab/icons/silk/ http://famfamfam.com/lab/icons/silk/].&lt;br /&gt;
&lt;br /&gt;
[[Image:Silkicon.theme.screenshot.jpg]]&lt;br /&gt;
&lt;br /&gt;
I have also uploaded the this file to this forum discussion if you would like to check it out for yourself.&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=151581 http://moodle.org/mod/forum/discuss.php?d=151581]&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
&lt;br /&gt;
* [[Themes 2.0]]&lt;br /&gt;
* [[Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Plugins]]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=151581 Using images within your themes (and the silk icon theme)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=151581#p689883 choosing images based on the users current language]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=157935&amp;amp;parent=691903 how to add a category(categorias) img-bullet]&lt;br /&gt;
* [[Replacing_icons_with_CSS3]]&lt;/div&gt;</summary>
		<author><name>Brianlmerritt</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Adding_courses_and_categories_to_the_custom_menu&amp;diff=37155</id>
		<title>Adding courses and categories to the custom menu</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Adding_courses_and_categories_to_the_custom_menu&amp;diff=37155"/>
		<updated>2013-01-10T18:50:18Z</updated>

		<summary type="html">&lt;p&gt;Brianlmerritt: /* How to add &amp;quot;My Courses&amp;quot; to the Custom Menu Bar for Moodle 2.4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello this is going to be a very brief tutorial on how to add a courses and categories tree to the custom menu.&amp;lt;br /&amp;gt;&lt;br /&gt;
The reason for writing this tutorial is simply that this seems to be a request that is being made over and over again.&lt;br /&gt;
&lt;br /&gt;
==Before we get started==&lt;br /&gt;
Please please please make sure you are familiar with the other Themes 2.0 tutorials before attempting this tutorial.&lt;br /&gt;
&lt;br /&gt;
In particular I would recommend being familiar with the following documents and tutorials as I&#039;m going to move through this tutorial at a fast pace.&lt;br /&gt;
&lt;br /&gt;
* [[Themes 2.0]]&lt;br /&gt;
* [[Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Themes 2.0 overriding a renderer]]&lt;br /&gt;
* [[Themes 2.0 extending the custom menu]]&lt;br /&gt;
&lt;br /&gt;
Providing you are familiar with the above you should manage just fine with this tutorial and if you ever get stuck don&#039;t forget to ask in the theme&#039;s forums, there is always someone around who can help.&lt;br /&gt;
&lt;br /&gt;
===Two words of warning===&lt;br /&gt;
&#039;&#039;&#039;First&#039;&#039;&#039; Just a quick warning here, this tutorial adds all categories and courses to the navigation, on a site with a large number of categories and/or courses this will be a performance hit. I would strongly suggest that if you are looking to implement something such as this on a large site that you talk to your system admin and/or resident developer about setting up a shared cache and caching the result of the get_course_category_tree method... it is a technical task but doing so will improve the performance of this extension on a large site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; If you have categories nested 2 or more deep then there is a chance that you will run into display problems with the custom menu on some themes... not too much you can do about it but if you encounter it with a core theme and you fix it perhaps you would be kind enough to create an issue in our bug tracker and share the fix. That&#039;d being said this is only a hunch I have all of the theme&#039;s may be fine :)&lt;br /&gt;
&lt;br /&gt;
==Laying the ground work==&lt;br /&gt;
Alright I don&#039;t want this tutorial to drag out so get ready. For this tutorial I am just going to extend the standard theme, I&#039;m going to make absolutely no changes to the design and layout of the theme or the custom menu I am ONLY going to add a list of courses and categories to it.&lt;br /&gt;
&lt;br /&gt;
So to begin with within your Moodle themes directory create a new directory coursecategorymenu in which I want you to create three files, the first config.php which is obviously required, the second renderers.php as we are going to achieve this by overriding a renderer, and the third the English language file for this theme.&lt;br /&gt;
&lt;br /&gt;
You should end up with:&lt;br /&gt;
&lt;br /&gt;
* moodle/theme/coursecategorymenu&lt;br /&gt;
* moodle/theme/coursecategorymenu/config.php&lt;br /&gt;
* moodle/theme/coursecategorymenu/renderers.php&lt;br /&gt;
* moodle/theme/coursecategorymenu/lang/en/theme_coursecategorymenu.php&lt;br /&gt;
&lt;br /&gt;
==config.php==&lt;br /&gt;
Obviously because all I want to base this theme off the standard theme and only override a renderer the config.php file is going to be VERY basic, so much so that I&#039;m not going to go into details about it, as you&#039;ve read the recommended tutorials you will already be completely familiar with everything it is doing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$THEME-&amp;gt;name = &#039;coursecategorymenu&#039;;&lt;br /&gt;
$THEME-&amp;gt;parents = array(&#039;standard&#039;, &#039;base&#039;);&lt;br /&gt;
$THEME-&amp;gt;rendererfactory = &#039;theme_overridden_renderer_factory&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==renderers.php==&lt;br /&gt;
This is of course where the magic is going to happen.&lt;br /&gt;
&lt;br /&gt;
In my case I want to add a branch to the end of the custom menu titled &#039;&#039;Courses&#039;&#039; and then I want to add the category and course structure to that branch.&lt;br /&gt;
&lt;br /&gt;
So like the [[Themes 2.0 extending the custom menu|extending the custom menu]] tutorial I will be overriding the core renderer and I will also be overriding the render_custom_menu_method.&lt;br /&gt;
&lt;br /&gt;
So the code for this:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
class theme_coursecategorymenu_core_renderer extends core_renderer {&lt;br /&gt;
 &lt;br /&gt;
    protected function render_custom_menu(custom_menu $menu) {&lt;br /&gt;
        // Our code will go here shortly&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll notice that is identical to the starting code for the extending custom menu tutorial.&lt;br /&gt;
&lt;br /&gt;
The difference comes in the code that we are going to populate it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
        &lt;br /&gt;
$branch = $menu-&amp;gt;add(get_string(&#039;courses&#039;, &#039;theme_coursecategorymenu&#039;), null, null, 10000);&lt;br /&gt;
&lt;br /&gt;
$categorytree = get_course_category_tree();&lt;br /&gt;
foreach ($categorytree as $category) {&lt;br /&gt;
    $this-&amp;gt;add_category_to_custommenu($branch, $category);&lt;br /&gt;
}&lt;br /&gt;
        &lt;br /&gt;
return parent::render_custom_menu($menu);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So lets work through this code line by line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This we need to do because we are going to use part of the course API, in particular a function called &#039;&#039;get_course_category_tree()&#039;&#039; that we&#039;ll look at shortly.&lt;br /&gt;
The function we want to use exists within the course lib file and in order to be sure its always available we need to include this file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$branch = $menu-&amp;gt;add(get_string(&#039;courses&#039;, &#039;theme_coursecategorymenu&#039;), null, null, 10000);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line adds the &#039;&#039;Courses&#039;&#039; branch to the custom menu into which we will add the category and course structure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$categorytree = get_course_category_tree();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line is the main one to note, here we are calling a Moodle function that will return us a category and course tree, because all courses need to be within a category the initial return is an array of categories, each category in the array will have the properties of the category as well as two additional properties, the first property &#039;&#039;&#039;categories&#039;&#039;&#039; is an array containing all of this categories sub categories, and the second property &#039;&#039;&#039;courses&#039;&#039;&#039; is also an array containing all of the courses within this category.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$categorytree = get_course_category_tree();&lt;br /&gt;
foreach ($categorytree as $category) {&lt;br /&gt;
    $this-&amp;gt;add_category_to_custommenu($branch, $category);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now these lines of code deal with the initial array of categories returned by the &#039;&#039;get_course_category_tree&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
In this case we iterate of the initial categories and for each one we call a method of the renderer &#039;&#039;&#039;add_category_to_custommenu&#039;&#039;&#039; now those of you who are clued in will realise that this method doesn&#039;t exist yet... and you are correct - we need to write this method which is what we will look at next.&amp;lt;br /&amp;gt;&lt;br /&gt;
As a heads up the reason that we need to write another method is because we need a method that we can call recursivily as there are potentially infinite category branches all contains sub categories and courses.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
return parent::render_custom_menu($menu);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The final line of code simply calls the original render_custom_menu method now that we have extended the custom menu as we want.&lt;br /&gt;
&lt;br /&gt;
Now that we have looked at the render_custom_menu lets write the function we just talked about &#039;&#039;&#039;add_category_to_custommenu&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&lt;br /&gt;
This function as discussed above is special in that we intend to call it recursively, that means we want to call it once for EVERY category that exists in the tree. We will need to give it the categories parent menu item as well as the category object we want added.&lt;br /&gt;
&lt;br /&gt;
Lets look at the code for this method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {&lt;br /&gt;
    $branch = $parent-&amp;gt;add($category-&amp;gt;name, new moodle_url(&#039;/course/category.php&#039;, array(&#039;id&#039; =&amp;gt;  $category-&amp;gt;id)));&lt;br /&gt;
    if (!empty($category-&amp;gt;categories)) {&lt;br /&gt;
        foreach ($category-&amp;gt;categories as $subcategory) {&lt;br /&gt;
            $this-&amp;gt;add_category_to_custommenu($branch, $subcategory);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    if (!empty($category-&amp;gt;courses)) {&lt;br /&gt;
        foreach ($category-&amp;gt;courses as $course) {&lt;br /&gt;
            $branch-&amp;gt;add($course-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $course-&amp;gt;id)), $course-&amp;gt;fullname);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ok so that doesn&#039;t look too bad, as you&#039;ve already read the extending custom menu tutorial you will be able to spot some of the things it is doing, none the less lets walk through the code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {&lt;br /&gt;
    .....&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First up the function definition, this function is going to be private because only we need it and it is going to take two arguments, the first $parent has to be a custom_menu_item, the second $category has to be the category object.&lt;br /&gt;
&lt;br /&gt;
The objective of this method is to add a category node to the custom menu, in regards to our arguments we want to add $category as a child of $parent.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$branch = $parent-&amp;gt;add($category-&amp;gt;name, new moodle_url(&#039;/course/category.php&#039;, array(&#039;id&#039; =&amp;gt;  $category-&amp;gt;id)));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line looks very familiar, here we are adding a node for the category to the $parent, we are also collecting the newly added node as $branch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if (!empty($category-&amp;gt;categories)) {&lt;br /&gt;
    foreach ($category-&amp;gt;categories as $subcategory) {&lt;br /&gt;
        $this-&amp;gt;add_category_to_custommenu($branch, $subcategory);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now this code is responsible for add the sub categories of this category to the menu as well, first we need to check that the categories property isn&#039;t empty (if it is there is nothing to add).&lt;br /&gt;
Assuming there are sub categories we need go through each of them and call this method on them so that they get added to the custom menu as well.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is called recursion.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if (!empty($category-&amp;gt;courses)) {&lt;br /&gt;
    foreach ($category-&amp;gt;courses as $course) {&lt;br /&gt;
        $branch-&amp;gt;add($course-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $course-&amp;gt;id)), $course-&amp;gt;fullname);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This code is very similar to the above code except that we are looking at the courses within this category.&amp;lt;br /&amp;gt;&lt;br /&gt;
Also note that this bit of code doesn&#039;t call add_category_to_custommenu recursivily, it doesn&#039;t need to as courses are the last bit we want to display on the menu within the category.&lt;br /&gt;
&lt;br /&gt;
And that is it, time to tidy up and we&#039;re done.&lt;br /&gt;
&lt;br /&gt;
==Finishing up==&lt;br /&gt;
All of the code is written now there is only last thing to do in order to tidy up however and that is to add the &#039;&#039;courses&#039;&#039; string that we used earlier... did you spot it?&lt;br /&gt;
&lt;br /&gt;
This is of course very easy, open up &#039;&#039;&#039;moodle/theme/coursecategorymenu/lang/en/theme_coursecategorymenu.php&#039;&#039;&#039; and add the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$string[&#039;courses&#039;] = &#039;Courses&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we&#039;re done. If you now browse to your site and change to the new theme you should see the Courses branch at the end of your custom menu that contains all of the categories, sub categories and courses for your site.&lt;br /&gt;
&lt;br /&gt;
==Full source==&lt;br /&gt;
===config.php===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$THEME-&amp;gt;name = &#039;coursecategorymenu&#039;;&lt;br /&gt;
$THEME-&amp;gt;parents = array(&#039;standard&#039;, &#039;base&#039;);&lt;br /&gt;
$THEME-&amp;gt;rendererfactory = &#039;theme_overridden_renderer_factory&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===renderers.php===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class theme_coursecategorymenu_core_renderer extends core_renderer {&lt;br /&gt;
 &lt;br /&gt;
    protected function render_custom_menu(custom_menu $menu) {&lt;br /&gt;
        global $CFG;&lt;br /&gt;
        &lt;br /&gt;
        require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
        &lt;br /&gt;
        $branch = $menu-&amp;gt;add(get_string(&#039;courses&#039;, &#039;theme_coursecategorymenu&#039;), null, null, 10000);&lt;br /&gt;
        &lt;br /&gt;
        $categorytree = get_course_category_tree();&lt;br /&gt;
        foreach ($categorytree as $category) {&lt;br /&gt;
            $this-&amp;gt;add_category_to_custommenu($branch, $category);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        return parent::render_custom_menu($menu);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {&lt;br /&gt;
        $branch = $parent-&amp;gt;add($category-&amp;gt;name, new moodle_url(&#039;/course/category.php&#039;, array(&#039;id&#039; =&amp;gt;  $category-&amp;gt;id)));&lt;br /&gt;
        if (!empty($category-&amp;gt;categories)) {&lt;br /&gt;
            foreach ($category-&amp;gt;categories as $subcategory) {&lt;br /&gt;
                $this-&amp;gt;add_category_to_custommenu($branch, $subcategory);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if (!empty($category-&amp;gt;courses)) {&lt;br /&gt;
            foreach ($category-&amp;gt;courses as $course) {&lt;br /&gt;
                $branch-&amp;gt;add($course-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $course-&amp;gt;id)), $course-&amp;gt;fullname);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===lang/en/theme_coursecategorymenu.php===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$string[&#039;courses&#039;] = &#039;Courses&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How to add &amp;quot;My Courses&amp;quot; to the Custom Menu Bar for Moodle 2.4==&lt;br /&gt;
&lt;br /&gt;
This adds a nice drop down for logged in users so they can easily see their relevant courses.  Note the code below has not been tested on Moodle 2.0-2.3, but you can find working code and instructions on how to add &amp;quot;My Courses&amp;quot; to the custom menu bar for those versions at: [[Themes_2.0_extending_the_custom_menu]]&lt;br /&gt;
&lt;br /&gt;
Below is the Moodle 2.4 custom menu code to add to theme/themename/renderers.php &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// Add the code below to Moodle 2.4   /theme/themname/renderers.php&lt;br /&gt;
&amp;lt;?php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class theme_themename_core_renderer extends core_renderer {&lt;br /&gt;
&lt;br /&gt;
    protected function render_custom_menu(custom_menu $menu) {&lt;br /&gt;
&lt;br /&gt;
        global $CFG;&lt;br /&gt;
        require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
&lt;br /&gt;
	// Moodle 2.4 doesn&#039;t appear to support $mycourses = $this-&amp;gt;page-&amp;gt;navigation-&amp;gt;get(&#039;mycourses&#039;); so &lt;br /&gt;
&lt;br /&gt;
	if (isloggedin() &amp;amp;&amp;amp; !isguestuser() &amp;amp;&amp;amp; $mycourses = enrol_get_my_courses(NULL, &#039;visible DESC, fullname ASC&#039;)) {  //which does work&lt;br /&gt;
&lt;br /&gt;
            $position_mycourses = 8000 ; // lower numbers = higher priority e.g. move this item to the left on the Custom Menu	&lt;br /&gt;
            $branchlabel = get_string(&#039;mycourses&#039;) ;&lt;br /&gt;
            $branchurl   = new moodle_url(&#039;/course/index.php&#039;);&lt;br /&gt;
            $branchtitle = $branchlabel;&lt;br /&gt;
            $branchsort  = $position;&lt;br /&gt;
            $branch = $parent-&amp;gt;add($branchlabel, $branchurl, $branchtitle, $branchsort);&lt;br /&gt;
			&lt;br /&gt;
      		foreach ($mycourses as $mycourse) {&lt;br /&gt;
			$branch-&amp;gt;add($mycourse-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $mycourse-&amp;gt;id)), $mycourse-&amp;gt;fullname);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
//Note to integrate this into the code for adding course and categories at the top of this document page, &lt;br /&gt;
//remove this class definition (you only need it once, and change the function name here to:&lt;br /&gt;
//&lt;br /&gt;
//     protected function render_mycourses_custom_menu(custom_menu_item $menu, $position) {&lt;br /&gt;
//&lt;br /&gt;
//then add a line in the original render_custom_menu function towards the end of it and invoke this function by&lt;br /&gt;
//&lt;br /&gt;
//     $this-&amp;gt;render_mycourses_custom_menu($menu, 12000) ;  &lt;br /&gt;
//&lt;br /&gt;
//&lt;br /&gt;
//Finally, don&#039;t forget to add the language definition for mycourses if that is not already set.  Bon chance!!&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note, in the comments I did also highlight the bit that doesn&#039;t work in Moodle 2.4.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Themes 2.0]]&lt;br /&gt;
* [[Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Themes 2.0 overriding a renderer]]&lt;br /&gt;
* [[Themes 2.0 extending the custom menu]]&lt;br /&gt;
* [http://developer.yahoo.com/yui/3/node-menunav/ YUI 3 Menunav component the custom menu uses]&lt;/div&gt;</summary>
		<author><name>Brianlmerritt</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Adding_courses_and_categories_to_the_custom_menu&amp;diff=37154</id>
		<title>Adding courses and categories to the custom menu</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Adding_courses_and_categories_to_the_custom_menu&amp;diff=37154"/>
		<updated>2013-01-10T18:47:44Z</updated>

		<summary type="html">&lt;p&gt;Brianlmerritt: Many users want to add &amp;quot;My Courses&amp;quot; to the custom menu, but the code doesn&amp;#039;t work for 2.4 so helping users by referencing the 2.0-2.3 code and including new code for 2.4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello this is going to be a very brief tutorial on how to add a courses and categories tree to the custom menu.&amp;lt;br /&amp;gt;&lt;br /&gt;
The reason for writing this tutorial is simply that this seems to be a request that is being made over and over again.&lt;br /&gt;
&lt;br /&gt;
==Before we get started==&lt;br /&gt;
Please please please make sure you are familiar with the other Themes 2.0 tutorials before attempting this tutorial.&lt;br /&gt;
&lt;br /&gt;
In particular I would recommend being familiar with the following documents and tutorials as I&#039;m going to move through this tutorial at a fast pace.&lt;br /&gt;
&lt;br /&gt;
* [[Themes 2.0]]&lt;br /&gt;
* [[Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Themes 2.0 overriding a renderer]]&lt;br /&gt;
* [[Themes 2.0 extending the custom menu]]&lt;br /&gt;
&lt;br /&gt;
Providing you are familiar with the above you should manage just fine with this tutorial and if you ever get stuck don&#039;t forget to ask in the theme&#039;s forums, there is always someone around who can help.&lt;br /&gt;
&lt;br /&gt;
===Two words of warning===&lt;br /&gt;
&#039;&#039;&#039;First&#039;&#039;&#039; Just a quick warning here, this tutorial adds all categories and courses to the navigation, on a site with a large number of categories and/or courses this will be a performance hit. I would strongly suggest that if you are looking to implement something such as this on a large site that you talk to your system admin and/or resident developer about setting up a shared cache and caching the result of the get_course_category_tree method... it is a technical task but doing so will improve the performance of this extension on a large site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; If you have categories nested 2 or more deep then there is a chance that you will run into display problems with the custom menu on some themes... not too much you can do about it but if you encounter it with a core theme and you fix it perhaps you would be kind enough to create an issue in our bug tracker and share the fix. That&#039;d being said this is only a hunch I have all of the theme&#039;s may be fine :)&lt;br /&gt;
&lt;br /&gt;
==Laying the ground work==&lt;br /&gt;
Alright I don&#039;t want this tutorial to drag out so get ready. For this tutorial I am just going to extend the standard theme, I&#039;m going to make absolutely no changes to the design and layout of the theme or the custom menu I am ONLY going to add a list of courses and categories to it.&lt;br /&gt;
&lt;br /&gt;
So to begin with within your Moodle themes directory create a new directory coursecategorymenu in which I want you to create three files, the first config.php which is obviously required, the second renderers.php as we are going to achieve this by overriding a renderer, and the third the English language file for this theme.&lt;br /&gt;
&lt;br /&gt;
You should end up with:&lt;br /&gt;
&lt;br /&gt;
* moodle/theme/coursecategorymenu&lt;br /&gt;
* moodle/theme/coursecategorymenu/config.php&lt;br /&gt;
* moodle/theme/coursecategorymenu/renderers.php&lt;br /&gt;
* moodle/theme/coursecategorymenu/lang/en/theme_coursecategorymenu.php&lt;br /&gt;
&lt;br /&gt;
==config.php==&lt;br /&gt;
Obviously because all I want to base this theme off the standard theme and only override a renderer the config.php file is going to be VERY basic, so much so that I&#039;m not going to go into details about it, as you&#039;ve read the recommended tutorials you will already be completely familiar with everything it is doing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$THEME-&amp;gt;name = &#039;coursecategorymenu&#039;;&lt;br /&gt;
$THEME-&amp;gt;parents = array(&#039;standard&#039;, &#039;base&#039;);&lt;br /&gt;
$THEME-&amp;gt;rendererfactory = &#039;theme_overridden_renderer_factory&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==renderers.php==&lt;br /&gt;
This is of course where the magic is going to happen.&lt;br /&gt;
&lt;br /&gt;
In my case I want to add a branch to the end of the custom menu titled &#039;&#039;Courses&#039;&#039; and then I want to add the category and course structure to that branch.&lt;br /&gt;
&lt;br /&gt;
So like the [[Themes 2.0 extending the custom menu|extending the custom menu]] tutorial I will be overriding the core renderer and I will also be overriding the render_custom_menu_method.&lt;br /&gt;
&lt;br /&gt;
So the code for this:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
class theme_coursecategorymenu_core_renderer extends core_renderer {&lt;br /&gt;
 &lt;br /&gt;
    protected function render_custom_menu(custom_menu $menu) {&lt;br /&gt;
        // Our code will go here shortly&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll notice that is identical to the starting code for the extending custom menu tutorial.&lt;br /&gt;
&lt;br /&gt;
The difference comes in the code that we are going to populate it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
        &lt;br /&gt;
$branch = $menu-&amp;gt;add(get_string(&#039;courses&#039;, &#039;theme_coursecategorymenu&#039;), null, null, 10000);&lt;br /&gt;
&lt;br /&gt;
$categorytree = get_course_category_tree();&lt;br /&gt;
foreach ($categorytree as $category) {&lt;br /&gt;
    $this-&amp;gt;add_category_to_custommenu($branch, $category);&lt;br /&gt;
}&lt;br /&gt;
        &lt;br /&gt;
return parent::render_custom_menu($menu);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So lets work through this code line by line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This we need to do because we are going to use part of the course API, in particular a function called &#039;&#039;get_course_category_tree()&#039;&#039; that we&#039;ll look at shortly.&lt;br /&gt;
The function we want to use exists within the course lib file and in order to be sure its always available we need to include this file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$branch = $menu-&amp;gt;add(get_string(&#039;courses&#039;, &#039;theme_coursecategorymenu&#039;), null, null, 10000);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line adds the &#039;&#039;Courses&#039;&#039; branch to the custom menu into which we will add the category and course structure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$categorytree = get_course_category_tree();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line is the main one to note, here we are calling a Moodle function that will return us a category and course tree, because all courses need to be within a category the initial return is an array of categories, each category in the array will have the properties of the category as well as two additional properties, the first property &#039;&#039;&#039;categories&#039;&#039;&#039; is an array containing all of this categories sub categories, and the second property &#039;&#039;&#039;courses&#039;&#039;&#039; is also an array containing all of the courses within this category.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$categorytree = get_course_category_tree();&lt;br /&gt;
foreach ($categorytree as $category) {&lt;br /&gt;
    $this-&amp;gt;add_category_to_custommenu($branch, $category);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now these lines of code deal with the initial array of categories returned by the &#039;&#039;get_course_category_tree&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
In this case we iterate of the initial categories and for each one we call a method of the renderer &#039;&#039;&#039;add_category_to_custommenu&#039;&#039;&#039; now those of you who are clued in will realise that this method doesn&#039;t exist yet... and you are correct - we need to write this method which is what we will look at next.&amp;lt;br /&amp;gt;&lt;br /&gt;
As a heads up the reason that we need to write another method is because we need a method that we can call recursivily as there are potentially infinite category branches all contains sub categories and courses.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
return parent::render_custom_menu($menu);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The final line of code simply calls the original render_custom_menu method now that we have extended the custom menu as we want.&lt;br /&gt;
&lt;br /&gt;
Now that we have looked at the render_custom_menu lets write the function we just talked about &#039;&#039;&#039;add_category_to_custommenu&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&lt;br /&gt;
This function as discussed above is special in that we intend to call it recursively, that means we want to call it once for EVERY category that exists in the tree. We will need to give it the categories parent menu item as well as the category object we want added.&lt;br /&gt;
&lt;br /&gt;
Lets look at the code for this method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {&lt;br /&gt;
    $branch = $parent-&amp;gt;add($category-&amp;gt;name, new moodle_url(&#039;/course/category.php&#039;, array(&#039;id&#039; =&amp;gt;  $category-&amp;gt;id)));&lt;br /&gt;
    if (!empty($category-&amp;gt;categories)) {&lt;br /&gt;
        foreach ($category-&amp;gt;categories as $subcategory) {&lt;br /&gt;
            $this-&amp;gt;add_category_to_custommenu($branch, $subcategory);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    if (!empty($category-&amp;gt;courses)) {&lt;br /&gt;
        foreach ($category-&amp;gt;courses as $course) {&lt;br /&gt;
            $branch-&amp;gt;add($course-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $course-&amp;gt;id)), $course-&amp;gt;fullname);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ok so that doesn&#039;t look too bad, as you&#039;ve already read the extending custom menu tutorial you will be able to spot some of the things it is doing, none the less lets walk through the code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {&lt;br /&gt;
    .....&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First up the function definition, this function is going to be private because only we need it and it is going to take two arguments, the first $parent has to be a custom_menu_item, the second $category has to be the category object.&lt;br /&gt;
&lt;br /&gt;
The objective of this method is to add a category node to the custom menu, in regards to our arguments we want to add $category as a child of $parent.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$branch = $parent-&amp;gt;add($category-&amp;gt;name, new moodle_url(&#039;/course/category.php&#039;, array(&#039;id&#039; =&amp;gt;  $category-&amp;gt;id)));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This line looks very familiar, here we are adding a node for the category to the $parent, we are also collecting the newly added node as $branch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if (!empty($category-&amp;gt;categories)) {&lt;br /&gt;
    foreach ($category-&amp;gt;categories as $subcategory) {&lt;br /&gt;
        $this-&amp;gt;add_category_to_custommenu($branch, $subcategory);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now this code is responsible for add the sub categories of this category to the menu as well, first we need to check that the categories property isn&#039;t empty (if it is there is nothing to add).&lt;br /&gt;
Assuming there are sub categories we need go through each of them and call this method on them so that they get added to the custom menu as well.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is called recursion.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
if (!empty($category-&amp;gt;courses)) {&lt;br /&gt;
    foreach ($category-&amp;gt;courses as $course) {&lt;br /&gt;
        $branch-&amp;gt;add($course-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $course-&amp;gt;id)), $course-&amp;gt;fullname);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This code is very similar to the above code except that we are looking at the courses within this category.&amp;lt;br /&amp;gt;&lt;br /&gt;
Also note that this bit of code doesn&#039;t call add_category_to_custommenu recursivily, it doesn&#039;t need to as courses are the last bit we want to display on the menu within the category.&lt;br /&gt;
&lt;br /&gt;
And that is it, time to tidy up and we&#039;re done.&lt;br /&gt;
&lt;br /&gt;
==Finishing up==&lt;br /&gt;
All of the code is written now there is only last thing to do in order to tidy up however and that is to add the &#039;&#039;courses&#039;&#039; string that we used earlier... did you spot it?&lt;br /&gt;
&lt;br /&gt;
This is of course very easy, open up &#039;&#039;&#039;moodle/theme/coursecategorymenu/lang/en/theme_coursecategorymenu.php&#039;&#039;&#039; and add the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$string[&#039;courses&#039;] = &#039;Courses&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we&#039;re done. If you now browse to your site and change to the new theme you should see the Courses branch at the end of your custom menu that contains all of the categories, sub categories and courses for your site.&lt;br /&gt;
&lt;br /&gt;
==Full source==&lt;br /&gt;
===config.php===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$THEME-&amp;gt;name = &#039;coursecategorymenu&#039;;&lt;br /&gt;
$THEME-&amp;gt;parents = array(&#039;standard&#039;, &#039;base&#039;);&lt;br /&gt;
$THEME-&amp;gt;rendererfactory = &#039;theme_overridden_renderer_factory&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===renderers.php===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class theme_coursecategorymenu_core_renderer extends core_renderer {&lt;br /&gt;
 &lt;br /&gt;
    protected function render_custom_menu(custom_menu $menu) {&lt;br /&gt;
        global $CFG;&lt;br /&gt;
        &lt;br /&gt;
        require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
        &lt;br /&gt;
        $branch = $menu-&amp;gt;add(get_string(&#039;courses&#039;, &#039;theme_coursecategorymenu&#039;), null, null, 10000);&lt;br /&gt;
        &lt;br /&gt;
        $categorytree = get_course_category_tree();&lt;br /&gt;
        foreach ($categorytree as $category) {&lt;br /&gt;
            $this-&amp;gt;add_category_to_custommenu($branch, $category);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        return parent::render_custom_menu($menu);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category) {&lt;br /&gt;
        $branch = $parent-&amp;gt;add($category-&amp;gt;name, new moodle_url(&#039;/course/category.php&#039;, array(&#039;id&#039; =&amp;gt;  $category-&amp;gt;id)));&lt;br /&gt;
        if (!empty($category-&amp;gt;categories)) {&lt;br /&gt;
            foreach ($category-&amp;gt;categories as $subcategory) {&lt;br /&gt;
                $this-&amp;gt;add_category_to_custommenu($branch, $subcategory);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if (!empty($category-&amp;gt;courses)) {&lt;br /&gt;
            foreach ($category-&amp;gt;courses as $course) {&lt;br /&gt;
                $branch-&amp;gt;add($course-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $course-&amp;gt;id)), $course-&amp;gt;fullname);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===lang/en/theme_coursecategorymenu.php===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$string[&#039;courses&#039;] = &#039;Courses&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How to add &amp;quot;My Courses&amp;quot; to the Custom Menu Bar for Moodle 2.4==&lt;br /&gt;
&lt;br /&gt;
This adds a nice drop down for logged in users so they can easily see their relevant courses.  Note the code below has not been tested on Moodle 2.0-2.3, but you can find working code and instructions on how to add &amp;quot;My Courses&amp;quot; to the custom menu bar for those versions at: [[Themes_2.0_extending_the_custom_menu]]&lt;br /&gt;
&lt;br /&gt;
Below is the Moodle 2.4 custom menu code to add to theme/themename/renderers.php &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// Add the code below to Moodle 2.4   /theme/themname/renderers.php&lt;br /&gt;
&amp;lt;?php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class theme_themename_core_renderer extends core_renderer {&lt;br /&gt;
&lt;br /&gt;
    protected function render_custom_menu(custom_menu $menu) {&lt;br /&gt;
&lt;br /&gt;
        global $CFG;&lt;br /&gt;
        require_once($CFG-&amp;gt;dirroot.&#039;/course/lib.php&#039;);&lt;br /&gt;
&lt;br /&gt;
	// Moodle 2.4 doesn&#039;t appear to support $mycourses = $this-&amp;gt;page-&amp;gt;navigation-&amp;gt;get(&#039;mycourses&#039;); so &lt;br /&gt;
&lt;br /&gt;
	if (isloggedin() &amp;amp;&amp;amp; !isguestuser() &amp;amp;&amp;amp; $mycourses = enrol_get_my_courses(NULL, &#039;visible DESC, fullname ASC&#039;)) {  //which does work&lt;br /&gt;
&lt;br /&gt;
            $position_mycourses = 8000 ; // lower numbers = higher priority e.g. move this item to the left on the Custom Menu	&lt;br /&gt;
            $branchlabel = get_string(&#039;mycourses&#039;) ;&lt;br /&gt;
            $branchurl   = new moodle_url(&#039;/course/index.php&#039;);&lt;br /&gt;
            $branchtitle = $branchlabel;&lt;br /&gt;
            $branchsort  = $position;&lt;br /&gt;
            $branch = $parent-&amp;gt;add($branchlabel, $branchurl, $branchtitle, $branchsort);&lt;br /&gt;
			&lt;br /&gt;
      		foreach ($mycourses as $mycourse) {&lt;br /&gt;
				    $branch-&amp;gt;add($mycourse-&amp;gt;shortname, new moodle_url(&#039;/course/view.php&#039;, array(&#039;id&#039; =&amp;gt; $mycourse-&amp;gt;id)), $mycourse-&amp;gt;fullname);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
//Note to integrate this into the code for adding course and categories at the top of this document page, remove this class definition (you only need it once, and change the function name here to:&lt;br /&gt;
//&lt;br /&gt;
//     protected function render_mycourses_custom_menu(custom_menu_item $menu, $position) {&lt;br /&gt;
//&lt;br /&gt;
//then add a line in the original render_custom_menu function towards the end of it and invoke this function by&lt;br /&gt;
//&lt;br /&gt;
//     $this-&amp;gt;render_mycourses_custom_menu($menu, $position_mycourses) ;  //$position_mycourses is the priority for custom menu &lt;br /&gt;
//&lt;br /&gt;
//Finally, don&#039;t forget to add the language definition for mycourses if that is not already set.  Bon chance!!&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note, in the comments I did also highlight the bit that doesn&#039;t work in Moodle 2.4. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Themes 2.0]]&lt;br /&gt;
* [[Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Themes 2.0 overriding a renderer]]&lt;br /&gt;
* [[Themes 2.0 extending the custom menu]]&lt;br /&gt;
* [http://developer.yahoo.com/yui/3/node-menunav/ YUI 3 Menunav component the custom menu uses]&lt;/div&gt;</summary>
		<author><name>Brianlmerritt</name></author>
	</entry>
</feed>