Include the contents of a text or html file in the current page at this point
Add block - Advanced - Advanced - Local file include
- The path is always relative to the root directory
- Non text based files cannot be included
- Included files can contain any other xt functions widgets or xtscript
A basic include function
<xt:include file="/folder/file" />
NOTE:Only the content between the <body>...</body>
tags is included from full HTML page files
The rest (all the headers) is discarded
Advanced (HTML only)
Include function with default for non existing files
Default must be declared first
This is mainly for includes that use xtgem "get" variables or are "printed" by xtscript
<xt:include default="/includes/default" file="/includes/no_such_file" />
Random file include
To include a random file from a folder use /* instead of a file name at the end of the path
<xt:include file="/random_includes/*" />
If you wish to use multiple random file includes you need to add another parameter/value pair
The name of the parameter and its value is not important it must be inserted before the file parameter and the value must be unique for each include or you will get the same included file
<xt:include x="1" file="/random_includes/*" />
<xt:include x="2" file="/random_includes/*" />
Regex filtered random file include
You can also use regular expressions (regex) to filter random includes
You can only use regex in the filename portion the folder must be declared
The regex must contain at least one *(regex include is a actually a bug in the random include function)
The multiple use trick will not work on regex random include
<xt:include file="/random_includes/a*[0-9]*.txt" />
Will only random include from files with names that start with the letter 'a' contains at least 1 number and have a '.txt' extension