Passing Directory Variables

Directory variables can be an important tool for a site developer or administrator. The concept is simple. Each directory variable has a property name, and a corresponding property value represented as a snippet of text. These variables have context. For instance, 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 a sibling directory such as the “/athletics” directory will not. However, this value is not permanently set as the value can be overridden further down in the directory structure by recasting a variable with the same name and different value.

Directory Variables


Using Directory Variables

The directory variable system was designed to serve multiple purposes. Currently, it has three pre-populated variable options, which can be used during the new page creation process and as a part of the XSL.

The three system variables will appear with the following names and accept the following values:

  • Name: Default Image Folder (formerly ox_ftp_image_root)
    • Value: root-relative or page-relative path to the desired image directory, no trailing slash (e.g. /campus-life/images or ./images)
  • Name: Default Media Folder (formerly ox_ftp_media_root)
    • Value: root-relative or page-relative path to the desired media directory, no trailing slash (e.g. /campus-life/videos or ./videos)
  • Name: Publish
    • Value: Add skip: and then make a comma-separated list of the file extensions that shouldn't be published (e.g. skip:xml,xsl,tcf,tmpl)

When the ox_ftp_image_root or ox_ftp_media_root are set for a given directory, a user will be placed into that set location when they use the Insert/Edit Image or Insert/Edit Embedded Media tools of the WYSIWYG Editor.

Directory variables can be used in:

  1. In the XSL
  2. In the echo var of the TMPL
  3. In the <directory-list>’s child nodes
  4. In the <template-list>’s child nodes
  5. In the <navigation-list>’s child nodes

Passing a Directory Variable to the TMPL

Using directory variables in the XSL allows the value to remain variable after page creation. Using a directory variable in the TMPL passes the current value at the time of page creation. Therefore, if the directory variable is updated later, the current pages will not be affected.

There are still valuable use cases for this. One such use case is to define a path for a filechooser that is part of the page properties. This can allow the default location to be based on the directory in which the page was created.

  1. Navigate to /_resources/ou/templates.
  2. Copy article.tmpl to the same directory, and rename it to pt-article.tmpl.
  3. Open and edit pt-article.tmpl.
  4. In the parameter named “article_image,” replace the current path (/_resources/images/news) with <!--%echo var="news-image" -->.
  5. Test by creating a new page, and then editing the page properties. Make sure to use the Page Templating New News TCF.