Path.php Global Variables

Within your path.php file, you can create global variables that are available to any Templates accessed through its associated index.php page (or whatever it might have been renamed).

Defining Variables

You may specify a PHP array containing "global variables" that will be available only to Templates accessed through that path.php file.

$global_vars = array(); // This array must be associative

For instance, let's say you want to define a weblog name and a Template Group name. You could use this:

$global_vars = array(
"my_weblog_name" => "news",
"my_template_group" => "display"
); // Last entry must not include the comma at the end

Within your Templates, you would then be able to use the {my_weblog_name} and {my_template_group} variables.

Using Conditionals

Global variables defined in the path.php file can be used in conditional statements within your Templates. For instance:

{if my_template_group == "display"}
Hey, it's the 'display' Template!
{/if}

In addition, they may be used with multiple conditions as described in the Conditional Global Variables page.

NOTE: It is not recommended that path.php global variables be used to hold HTML, ExpressionEngine tags, or PHP, as these and all inputted variables are sanitized for security reasons.

Top of Page

User Contributed Notes

Posted by: KeithW on 27 February 2009 1:09am
no avatar

These “Global Variables” are the “MANUALLY CONFIGURABLE VARIABLES” referred to in the path.php file.

Posted by: mhulse on 27 July 2008 4:12pm
no avatar

Alternatively (or in conjunction with path.php):

Fresh Variables

“Allows you to create and manage early-parsed global variables from the control panel.”

“NOTE: Unlike path.php global variables, Fresh Variables can be used to contain HTML, ExpressionEngine tags, and even PHP, so bear this in mind when granting access to the module.”

You must have an ExpressionEngine license and have attained a forum rank of "Lab Assistant" (100 posts) to contribute notes to the User Guide