User Tools

Site Tools


theme:advanced

Partial Template Files

It can be useful to break up page template files into parts, especially if you have several page templates and wish to use the same code in each of them. Partial Template Files are given a .inc.php extension.

Optimal Theme Files Layout

The use of other files are completely up to the theme developer. Most of the time, it would be best to break the template.php file down into a couple other files such as header.inc.php, footer.inc.php, sidebar.inc.php and style.css. These files can then be included into the template.php file.

Example usage to include footer.inc.php, at the end of a template file:

<?php include('footer.inc.php'); ?>

The file names listed above are completely arbitrary, but demonstrate a good semantic approach to laying out a theme. If you break out certain parts of the template you may reuse some code and it'll be easier to update it.

As of 3.1, you can force the page editor's “Template” dropdown to ignore partial template files by naming them with a .inc.php extension. For example, a user will not be able to choose footer.inc.php as a page template because its file extension will prohibit it from ever showing in the select box.

Theme Functions File

Developers also have the ability to include certain PHP functions within their theme by using the functions.php file. This will be placed in the same folder as the template.php file. The functions file can be used for just about anything to do with PHP as it is automatically included by GetSimple before the theme is loaded.

theme/advanced.txt · Last modified: 2013/04/19 15:04 (external edit)