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.
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:
- In the XSL
- In the echo var of the TMPL
- In the <directory-list>’s child nodes
- In the <template-list>’s child nodes
- 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.
- Navigate to /_resources/ou/templates.
- Copy article.tmpl to the same directory, and rename it to pt-article.tmpl.
- Open and edit pt-article.tmpl.
- In the parameter named “article_image,” replace the current path (/_resources/images/news) with <!--%echo var="news-image" -->.
- Test by creating a new page, and then editing the page properties. Make sure to use the Page Templating New News TCF.