We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Early Globalvars

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

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!

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Just curious, what exactly is wrong with Fresh variables? Unless I am mistaken they were meant to be exactly that, early parsed global variables?

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas
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?

       
DEA's avatar
DEA
257 posts
16 years ago
DEA's avatar DEA

Don’t fresh variables fail to work in IE6/7 as well?

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Yes, you need a a DOM-compliant web browser for modifying the variables via the backend. Of course that does not matter in the site’s day to day operations.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.