Includes
Includes can be used for both dynamic and static content. For dynamic content you can use PHP code. It has to be surrounded by <?php and ?> as usual.
Accessing PHP variables
It is possible to access the variables of the CMS. As an example, this allows to execute a different action depending on the page that is being loaded. The global keyword must be used, because includes are executed within a function.
The two most important variables
- $current_page: unique short URL of the current page
- $query_string_data: data in the URL after the separator
Example
If the URL was http://domain.tld/index.php?pagename/text the variables would have the following contents:
- $current_page: pagename
- $query_string_data: text
Accessing the template
The template class is available under the PHP variable $this and doesn't have to be imported using the global keyword. All functions of the template class can be used.
Accessing Page Attributes
Page attributes can be set individually for each page in the admin area and are available in the PHP variable $attributes. As described above, the global keyword must be used for accessing the variable.
This variable is an array that contains the individual attributes. Each attribute is another array, of which the first value gives you the name and the second value the content of the attribute.
Example
global $attributes; foreach($attributes as $attr) { list($attr_name, $attr_data) = $attr; // $attr_name and $attr_data have to be processed here }
Inserting Includes
Includes can be inserted in pages and the template using the cotresponding variable. An include with the name Example would be inserted by writing %%INCLUDE-Example%%.
An alternative way for inserting includes is to write %%LATEINCLUDE-Name%%. The include will then be executed at the latest possible time, which allows for example replacements on the page using the template engine.
For the insertion of another include inside a include you have to use PHP. The code needed for inserting the include Example is shown in the following example:
<?php include('./data/includes/Example'); ?>