Knowledgebase: PHP Templating Reference
Templating Elevated X using the PHP Templating Language
Posted by Mark [Elevated X Support], Last modified by Mark [Elevated X Support] on 14 February 2017 11:06 PM

Templating Elevated X using the PHP Templating Language

About PHP:

PHP is a popular general-purpose scripting language that is especially suited to web development. The Elevated X CMS itself is written in PHP.

What this means for you is that the Elevated X CMS provides data which is available within your own PHP template files. These template files control the formatting of this data.


PHP Syntax:

You can find out more about PHP syntax here:
http://php.net/

If you're getting started with PHP, w3schools has a tutorial on it here:

http://www.w3schools.com/php/


Template Files:

By default, the template that the system uses is based on the name of the file that's being called.  For instance:
gallery.php uses /cms_admin/phptemplate/<templatefolder>/gallery.tpl
index.php uses /cms_admin/phptemplate/<templatefolder>/index.tpl
category.php uses /cms_admin/phptemplate/<templatefolder>/category.tpl

Tours generally use the file tour1.tpl or tour.tpl

Where <templatefolder> is the template folder currently in use. By default, new installs use the folder "site0" for standard templates, and "site0_mobile" for mobile templates.

 
Data:

Within the Elevated X PHP template system, we have a set of variables that are available for use within the templates.

To see the list of variables available, you can access our object browser by adding:

debug=1

to your URL. Examples of this are:

e.g: http://yoursite.com/members/?debug=root
e.g: http://yoursite.com/members/gallery.php?id=171&type=vids&debug=root

Or on our live demo:

http://allaccess.elevatedx.com/members_php/?debug=1


By adding this to your page URL as a PHP argument, you'll be able to see all of the variables available to your templates, along with some documentation on what each variable does.If there is a plus sign (+) next to the variable, you can expand it to see information about what information is stored in that variable.

Within your templates, you can take these variables, and dump them to the screen. One way of doing this is:
<pre>
<?php print_r($plugins); ?>
</pre>

In this case, this will dump a list of plugins that are available and enabled on your system.

Another example is:
<pre>
<?php print_r($sets); ?>
</pre>

If you're on a page that lists scenes, this will dump a list of scenes that are available on this page.



Includes:

Our CMS templates do not include the entire page's logic within one single template file.  Instead, we split the logic into separate files that can be then "included" into the template using the include tag.

Here's an example from index.tpl:

<?php foreach ($sets as $set) { ?>
  <div class="latest_updates_wrapper">
    <?php LoadTemplate("template_sections/update_table.tpl", ["set" => $set]); ?>
  </div>
<?php } ?>


Here's what this piece of code does:

    •    <?php foreach ($sets as $set) { ?>: This tag cycles (or loops) through what is known as an array.  In this case, the array is $sets. In each cycle, the loop creates a variable called $set. $set denotes a single scene.

    •    <?php LoadTemplate("template_sections/update_table.tpl", ["set" => $set]); ?>.  This will call out to a separate template.  It will pass along the variable $set, so it can be used in that sub-template.

    •    <?php } ?>: This closes the loop


Elevated X commands that will help:

1) highlevelcachedebug=1

By adding this to a page URL, you will see vital caching information, such as which template folder is in use:

e.g: http://allaccess.elevatedx.com/members_php/?highlevelcachedebug=1
e.g: http://allaccess.elevatedx.com/members_php/gallery.php?id=171&type=vids&highlevelcachedebug=1

Here, you'll be able to see that the "phpfolder" for this site is "site0".  This maps to the path:
/cms_admin/phptemplate/site0/

within the CMS.


(7 vote(s))
Helpful
Not helpful

Comments (0)