Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Theme directory guide: Difference between revisions

From MoodleDocs
Line 14: Line 14:
'''This variable will be introduced in version 1.7'''
'''This variable will be introduced in version 1.7'''


The ''$CFG->httpsthemewww'' variable contains the same information as $CFG->themewww with the correct http/https prefix. This  should be used to provide proper operation of https protected pages.
The ''$CFG->httpsthemewww'' variable contains the same information as $CFG->themewww with the correct http/https prefix. This  should be used to provide proper references to files on pages which could be https protected.


== $CFG->themedir ==
== $CFG->themedir ==

Revision as of 14:37, 8 October 2006


In the standard Moodle distribution, all themes are placed in the theme/ directory, this leads to developers hardcoding this location into their themes and references to themes. Developers should not take this location for granted, instead using the variables which moodle provides for the purpose of specifying a theme location.

Starting with 1.7, moodle will fully support changing the location which themes are stored in. Developers need to ensure they are using the provided variables to ensure compatibility with this feature.

$CFG->themewww

This variable has been available since version 1.5.1

The $CFG->themewww variable contains the web-accessible location of the theme directory. If it is not set by the site administrator it will be the default of $CFG->wwwroot . '/theme'. i.e. 'http://my.moodle.site/theme'.

$CFG->httpsthemewww

Moodle1.7

This variable will be introduced in version 1.7

The $CFG->httpsthemewww variable contains the same information as $CFG->themewww with the correct http/https prefix. This should be used to provide proper references to files on pages which could be https protected.

$CFG->themedir

This variable has been available since 1.5.1

The $CFG->themedir variable contains the local location on the moodle server of the theme directory. If it is not set by the site administrator it will be the default of $CFG->dirroot . '/theme'. i.e. '/my/moodle/location/theme'.

How to refer to the directory of the current theme

The most common use of the theme directories will be used to specify the current theme directory for inclusion/display of files.

The correct way to do this is:

$CFG->themewww .'/'. current_theme()  

Or to include a theme file:

$CFG->themedir .'/'. current_theme()