Template structure and multiple languages
Templates contain the HTML code. They can be nested. This is useful to split up components like header, footer or navigation into separate templates and include them from the main template later on.
Websites usually require multiple templates like one column or two column layouts. We recommend you to avoid HTML code in user selectable templates (where “Active” is checked) but make them include other templates only. This is good practice to keep your HTML code in one place. Have a look at how the demo handles it:
<?php
// Two columns template
// Define constant SITE_TYPE
define('SITE_TYPE', 'col2');
?>
<!-- Request the template containing the HTML code -->
REX_TEMPLATE[3]
The main template with ID 3, containing most of the HTML code, checks for the page type. Segments like header and footer are included from separate templates. This probably helps you focus on particular sections when working with code. However, you can store all your code in a single template, if you like to.
<?php
// Content will show up in full column layout if global variable is "col1".
if (SITE_TYPE == 'col1') {
echo '
<div class="container mtb">
<div class="row">
'.$this->getArticle('1').'
</div>
</div>';
// Use 2/3 width main column with 1/3 width side column if global variable is "col2".
} elseif (SITE_TYPE == 'col2') {
echo '
<div class="container mtb">
<div class="row">
<div class="col-lg-8">
'.$this->getArticle('1').'
</div>
<div class="col-lg-4">
'.$this->getArticle('2').'
</div>
</div>
</div>';
}
?>