Content / Theme basics / File "theme.php"


File "theme.php"

Information you can find in theme.php

comments: 0
If you open the file with a (utf8 capable) text editor, you will find following code lines using different variables:


define("BOOTSTRAP", 	3);
define("FONTAWESOME", 	4);
define('VIEWPORT', 		"width=device-width, initial-scale=1.0");
define('BODYTAG', '<body class="body-class '.THEME_LAYOUT.'">');

Version 2 Description
BOOTSTRAP on many places are switches between old and new ways of templating. It doesn’t mean that bootstrap is used (but better if it is). Without it your site can look different (f.e. Tables instead divs etc). If you want to know where this is important, just check source code for: if(deftrue("BOOTSTRAP")
FONTAWESOME for switching if to use ( display ) icons or images. Used mainly in forum.
VIEWPORT used for meta tag viewport in header_template.php (proper rendering and touch zooming if applicable)
BODYTAG it’s used when you need special class/selector for . It overrides default selector id=layout-xxx.

There are still constants used in code from version 1 (I just let them there because default theme use them too):

// Legacy Stuff.
define('OTHERNEWS_COLS',false); // no tables, only divs. 
define('OTHERNEWS_LIMIT', 3); // Limit to 3. 
define('OTHERNEWS2_COLS',false); // no tables, only divs. 
define('OTHERNEWS2_LIMIT', 3); // Limit to 3. 
define('COMMENTLINK', 	e107::getParser()->toGlyph('fa-comment'));
define('PRE_EXTENDEDSTRING', '<br />');

Update 2017/09: COMMENTLINK has default value in core, so no need to use it in theme.php, only if you want to have your own.

Example of constants you can find in old themes:

Constant Description
define("STANDARDS_MODE", TRUE); Mainly IE ; correct boxmodel (legacy)
define("IMODE", "lite"); Icon-set use (eg forum dark/lite (legacy)
define("THEME_DISCLAIMER", "<br /><i>".LAN_THEME_1."</i>"); theme disclaimer (themeinfo)
define('WMFLAG', ''); Welcome message is not displayed at all, use {WMESSAGE=hide} now


It’s something new from latest versions. Before you needed to load bootstrap and fontawesome files standard way (see bellow), now you can load them with “library” and in admin area you can set source for them (local, CDN…) theme.xml by adding elements
		<library name="bootstrap" scope="all"/>
		<library name="fontawesome" scope="all"/>

2. in theme.php by using library
e107::library('load', 'bootstrap');
e107::library('load', 'fontawesome');

If you want to use local versions, just set it in Settings/ Libraries


Without libraries you need load these files via e107::css()and e107::js()

Load theme css and js files

For detailed information see Developer Manual

Examples related to theming:

IE fix:
e107::js('url','','','2','<!--[if lt IE 9]>','');

Activate bootstrap tooltips :
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})");

Load scripts after JQuery:
e107::js("theme", "js/scripts.js", 'jquery');

Load translated strings


For Frontend your language strings should be a file with name English.php (or your language). For Admin part there should be a English_admin.php file (or your language). Both reside in languages folder inside your theme.