Directory Variables

Contents

  1. Intro
  2. Uses
  3. Totorial

Directory variables can be an important asset to a site developer or administrator. The concept is simple: each directory variable has a name, and a corresponding value represented as a snippet of text.

These variables have context - applying a directory variable to the "/academics" folder will set that value for that directory and all of the directories below it. Therefore, "/academics/biology" will have this value defined, but the "/athletics" directory will not. However, this value is not set permanently - the value can be overridden further down in the directory structure by simply reusing the same name.

Uses

The directory variable system was designed to serve multiple purposes. Currently, it has two: pre-populated variables which can be used during the new page creation process (along with TCFs), and contextual system configuration information.

Contextual Configuration Information

One value is supported at this time; more may be added as the product evolves:

  1. "ox_ftp_image_root": Redefines the default image directory in the WYSIWYG editor, the default value of which is found in the site setup.

 


Pre-Populated Variables

Since they're snippets of text, these directory variables can hold anything that a standard variable defined in a TCF could. Directory variables simply allow you to store them in a contexual manner, where the value may change based on the current location. Some possibilities include:

  1. Path to a CSS file which may change a color scheme or background image based on the section of the site.
  2. Contact information for the maintainer of that portion of the website.

 

Both contexutal configuration information and pre-poulated variables are accessible in TMPL files when creating a new file, though it's not as likely that contextual configuration information will be echoed into a file.

Tutorial

Directory variables are defined per-directory using the same interface as other directory properties, such as access permissions and RSS feed settings, in the access screen:

screenshot of directory access

Two sections will show up - some non-editable inherited values, and an editable list of entries for the current directory. To create a new variable, simply enter a variable name on the left (what you would use in your <!--%echo var="NAME" --> tag) and a value on the right (what that <!-- --> tag would be replaced with upon creation). Please refrain from naming variables with names that begin with "ox_" as these are reserved for future development purposes.

To override a variable with a new value, simply reuse the variable name in the editable portion of the screen - the new value will replace the old when the variable's contents are accessed.

After saving your access preferences, your directory variables are immediately accessible in the current directory and all directories below it, including contextual configuration information and pre-populated variables.

Tip: Define a variable's default value using the access button for the top of the site (found under the setup tab), and redefine it to have intended values further down in the directory structure. This eliminates the possibility of having an empty string ('') used during the variable substitution in TMPL files.