The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.
The purpose of this plugin is early parsing of global template variables.
Global template variables can be set in Control Panel > Templates page. Global template variables are one of the last things parsed in your templates. This means that you cannot use a global template variable as the value for an EE Tag parameter.
It is possible to get early-parsed global variables by editing path.php file and by installing Fresh Variables module/extension.
Both methods of getting early-parsed global variables does’nt appear to me nice. The first requires using FTP; the second means storing global variables as settings of Fresh Variables extension.
Since I didn’t like these methods I started thinking about other methods getting early-parsed global variables. The solution I found is this: istead of using path.php variables or Fresh Variables module/extension it would be much nicer to get early parsing of global template variables just in cases when it is needed by using a plugin. That is, when you need early-parsed global variable you need just to wrap the piece of code containing global template variables with plugin’s tags.
PARAMETERS
1) globalvar - Required. Allows you to specify names of template global variables. You can stack names of template global variables using pipe character e.g. globalvar=”main_date_format|comment_date_format”.
2) site - Optional. Allows you to specify site id. Default value is “1”.
USAGE
Wrap the piece of code in which global tempate variables should be parsed early with {exp:early_globalvars}{/exp:early_globalvars} tag pair:
{exp:early_globalvars globalvar="comment_date_format" parse="inward"}
{exp:comment:preview}
{comment_date format="{comment_date_format}"}
{/exp:comment:preview}
{/exp:early_globalvars}
{exp:early_globalvars} must have parse=”inward” parameter!
what exactly is wrong with Fresh variables? Unless I am mistaken they were meant to be exactly that, early parsed global variables?
I do not like the main idea of Fresh Variables - burying global variables as settings of an extension. This looks like a crude hack. Global variables is an important concept and they really deserve to be stored in a separate database table; such a table which would remain intact after uninstallation of any add-on. Since there is already a database table used for storing global variables, why not use it both for storing lately-parsed and early-parsed global variables?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.