xt include
Include the contents of a text or html file in the current page at this point
Add block - Advanced - Advanced - Local file include
Select a text based file to include using the filebrowser
- Non text based files cannot be included
- Included files can contain any other xt functions widgets or xtscript
Example plain text file for include
<div>
<span style="color:yellow">This is a simple included file</span>
</div>
Example of included plain text file
This is a simple included file
Including HTML files
NOTE:Only the content between the <body>...</body>
tags is included from HTML files
The rest is discarded
Example HTML file for include
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Test include</title>
<span>This is NOT included as it is in the headers before the body tag</span>
</head>
<span>Nor this</span>
<body>
<span style="color:orange">Included content starts after the body tag</span><br />
<div class="note">
<span>This is an included html file</span><br />
<span>Note that the content outside the body tags has been discarded</span><br />
</div>
<span style="color:aqua">Included content ends before the /body tag</span>
</body>
<span>This is NOT included as it is after the /body tag</span>
</html>
Example of included HTML file
Included content starts after the body tag
This is an included html file
Note that the content outside the body tags has been discarded
Included content ends before the /body tag
Advanced
The basic include function as used above
The included files path is relative to the root directory
<xt:include file="/includes/html_page" />
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" />
This is the default file that gets included if the other one does not exist
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 file
<xt:include x="1" file="/random_includes/*" />
<xt:include x="2" file="/random_includes/*" />
reload