Automatically exported variables
Vanilla_Web_Page_View automatically exports following "system" variables:
- _path - contains full absolute path to hidden/tpl/ directory. Example: /var/www/sites/tft/hidden/tpl/
- _page - page name (set in interceptor (
$page = new My_Page_WP('my_page');) or WP constructor). Example value: my_page. - _view - view name (set when creating the view in
init() ($v = new Site_Web_Page_View($this);)). Example values: default, my_view - _subdir - subdir. It is used when additional grouping of files is needed in hidden/tpl/. Usually you need this if you need to separate for example TPLs for admin panel pages from TPLs for public site pages.
- _language - two letter code of current language. Example values: en, bg. Default and supported languages are defined in hidden/conf/site_specific.conf. Language detection and management is provided by language_detector_* modules.
- _current_host - current host. Example values: tft.myhost, tft.somedomain123.com
- _current_port - current port. Example values: 80, 8080
- _current_protocol - current protocol. Example values: http, https
- _additional_csses - array that contain list of additional CSS files. You can add your own values to this array using
$view->add_css('path_to_css_file'). TPL file that contains <head> element must process this in order to work (i.e. has
{foreach from=$_additional_csses item=_css}<link rel="stylesheet" type="text/css" href="/css/{$_css}" />{/foreach}
) - _additional_jses - array that contain list of additional javascript files. You can add your own values to this array using
$view->add_js('path_to_js_file'). Again TPL file that contains <head> element must process this with {foreach} (see above).
Additionally Vanilla WP exports:
- _base_url - Base URL is autodetected when site is booted. Main TPL uses $_base_url in head like:
<base href="{$_base_url}" />
. - _site_mode - there are two site modes: development(0) and production(1). In development mode you may expect some TPLs to render debug information. _site_mode is set in machine_specific.global.conf
- _default_encoding - default character encoding. Used by main TPL in
<meta http-equiv="Content-Type" content="text/html; charset={$_default_encoding}" />
. _default_encoding is set in machine_specific.global.conf
- _server_error_page - relative path to server error page. Default is
server_error.php. _server_error_page is set in site_specific.conf - _instance_name name of the current installation. It is a free form string. Usual values are development and production but you can name it whatever you want. The idea behind exporting this variable is to be able to distinguish different installations of one and the same application. For example: usually you have one development installation used to test new changes and one production installation. To avoid confusion which installation you are using at given moment - you may show this variable in noticeable way so you don't for example accidentally delete all users from production installation while thinking that you are in dev installation.