Reserved
The PHP reserved {$tplix} variable can be used to access several environment and request variables. The full list of them follows.
Request variablesThe request variables such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION can be accessed as demonstrated in the examples below:
{* display value of page from URL ($_GET) http://www.example.com/index.php?page=foo *}
{$tplix.get.page}
{* display the variable "page" from a form ($_POST['page']) *}
{$tplix.post.page}
{* display the value of the cookie "username" ($_COOKIE['username']) *}
{$tplix.cookies.username}
{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$tplix.server.SERVER_NAME}
{* display the system environment variable "PATH" *}
{$tplix.env.PATH}
{* display the php session variable "id" ($_SESSION['id']) *}
{$tplix.session.id}
{* display the variable "username" from merged get/post/cookies/server/env *}
{$tplix.request.username}
For historical reasons {$SCRIPT_NAME} is shorthand for {$tplix.server.SCRIPT_NAME}.
<a href="{$SCRIPT_NAME}?page=tplix">click me</a>
<a href="{$tplix.server.SCRIPT_NAME}?page=tplix">click me</a>
Although tplix provides direct access to PHP super globals for convenience, it should be used with caution. Directly accessing super globals mixes underlying application code structure with templates. A good practice is to assign specific needed values to template vars.
{$tplix.now}
The current timestamp can be accessed with {$tplix.now}. The value reflects the number of seconds passed since the so-called Epoch on January 1, 1970, and can be passed directly to the date_format modifier for display. Note that time() is called on each invocation; eg a script that takes three seconds to execute with a call to $tplix.now at start and end will show the three-second difference.
{* use the date_format modifier to show current date and time *}
{$tplix.now|date_format:'%Y-%m-%d %H:%M:%S'}
{$tplix.const}
You can access PHP constant values directly.
<?php
// the constant defined in php
define('MY_CONST_VAL','CHERRIES');
Output the constant in a template with
{$tplix.const.MY_CONST_VAL}
Although tplix provides direct access to PHP constants for convenience, it is typically avoided as this is mixing underlying application code structure into the templates. A good practice is to assign specific needed values to template vars.
{$tplix.config} variable can be used to refer to loaded config variables. {$tplix.config.foo} is a synonym for {#foo#}. See the {config_load} page for more info.
{$tplix.template}Returns the name of the current template being processed (without the directory).
{$tplix.template_object}Returns the template object of the current template being processed.
{$tplix.current_dir}Returns the name of the directory for the current template being processed if it is loaded from the filesystem (the default).
{$tplix.version}Returns the version of tplix the template was compiled with.
<div id="footer">Powered by tplix {$tplix.version}</div>
{$tplix.ldelim}, {$tplix.rdelim}
These variables are used for printing the left-delimiter and right-delimiter value literally, the same as {ldelim},{rdelim}.