Knowledge Base

File theme.php

Information you can find in theme.php
on Monday 01 July 2019
comments: 0
Updated for version 2.2.2

Constants

No constants should be used in theme.php now. 

define("BOOTSTRAP", 3);

define("FONTAWESOME", 4);

should be replaced in theme.xml file by:

bootstrap 3:

<libraries>
<library name="bootstrap" scope="all"/>
<library name="fontawesome" scope="all"/>
</libraries>

bootstrap 4:

<libraries>
<library name="bootstrap" version="4" scope="all"/>
<library name="fontawesome" version="5" scope="all"/>
</libraries>

define('BODYTAG', '<body class="body-class '.THEME_LAYOUT.'">');

should by in theme.html replaced by

<body id="page-top" class="{LAYOUT_ID}" {BODY_ONLOAD} >

 


define('VIEWPORT', "width=device-width, initial-scale=1.0");

should be replaced in theme.php

e107::meta('viewport', 'width=device-width, initial-scale=1.0');

it is used for meta tag viewport in header_template.php (proper rendering and touch zooming if applicable)

No legacy stuff should be used in themes for version 2.2.2

 

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

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('COMMENTOFFSTRING', '');

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

Libraries

load core libraries directly in theme.php is not needed anymore, theme.xml is enough

e107::library('load', 'bootstrap');

e107::library('load', 'fontawesome');

Load theme css and js files

For detailed information see Developer Manual Examples related to theming: IE fix:

e107::js('url','https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js','','2','<!--[if lt IE 9]>','');
e107::js('url','https://oss.maxcdn.com/respond/1.4.2/respond.min.js','','2','','<![endif]-->');

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

e107::lan('theme');

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