GeeVar, an ExpressionEngine add-on by Studio625

Documentation

Setup

Setting up GeeVar requires the creation of a new custom weblog field group and a new weblog.

Creating the new custom field group

  1. In the control panel, go to Admin -> Weblog Management -> Create a New Weblog Field Group.
  2. Call the new group whatever you like, i.e. "Global Variables". Submit.
  3. Click "Add/Edit Custom Fields" next to the group you just created, then Create a New Custom Field.
  4. This field will contain the value of the variable. It should be named in the format myprefix_value, where myprefix_ is up to you. We suggest something like "geevar_" or "global_". Important: Remember the prefix you've chosen. We will use it later.
  5. Set the Field Type to Textarea, and Textarea Rows to whatever you prefer.
  6. Set the default formatting to whatever you prefer. We suggest "none", but the value you choose will depend on your intended use of the variables you create.
  7. This is a required field.
  8. We recommend not allowing the field to be searchable.
  9. The field should be shown by default.
  10. The display order should be 1.
  11. Submit.

Creating the new weblog

  1. In the control panel, go to Admin -> Weblog Management -> Create a New Weblog.
  2. Name the weblog however you like, i.e. "Global Variables".
  3. Give the weblog a short name, i.e. global_variables.
  4. Edit Group Preferences, and choose the custom field group you created above.
  5. Submit.

Modifying the weblog's preferences

  1. Click "Edit Preferences" next to the weblog you just created.
  2. Click "Publish Page Customization".
  3. In the "URL Title Prefix" field, enter the prefix you used when creating the custom field above.
  4. Click Update.

Creating Variables

Creating variables is as easy as creating a new weblog entry. Simply choose the weblog you created from the Publish menu in the control panel.

Variable Name. The url title is used as the variable's name in the templates, so give the variable a title that makes sense. Something like "Company Address" or "Homepage Welcome Message", which become myprefix_company_address and myprefix_homepage_welcome_message.

Variable Value. Enter the variable's value in the custom field you created. Set the field formatting as appropriate.

Nesting Variables

GeeVar allows you to nest variables. For example, you could have a "world" variable with the value "World", and a "hello_world" variable with the value "Hello {geevar_world}!". The output would be "Hello World!". There are checks in place to help prevent infinite recursion.

In the Templates

Using GeeVar in the templates is as simple as wrapping {exp:geevar} tags around the content you want processed.

Parameters

weblog="global_variables" -- Enter the short name of the custom weblog you created. Required.

var_prefix="geevar_" -- The prefix value you used during the setup process. Default is "geevar_".

Variables

The variables are in the format myprefix_variable_name. Using the homepage welcome message example from above, your template might look like:

{exp:geevar weblog="global_variables"}
<p>Here is a hello from our company:</p>
{geevar_homepage_welcome_message}
{/exp:geevar}

Meta Variables

A number of "meta" variables are available. They provide information about the Geevar variable. The most commonly used include date variables like entry_date and expiration_date (described below), and status. Meta variables have the format {myprefix_variable_name:date_variable}.

{geevar_homepage_welcome_message:status}

Date Variables

Date variables are in the format {myprefix_variable_name:date_variable format="%Y-%m-%d"}. For example:

{geevar_homepage_welcome_message:entry_date format="%Y-%m-%d"}

Available date variables are: entry_date, expiration_date, and edit_date.

Conditionals

Geevar's variables and meta variables can be used in standard EE conditionals, i.e.

{if geevar_homepage_welcome_message:status == 'open'}Woohoo!{if:else}Boo!{/if}