User Tools

Site Tools


ru:theme:advanced

This is an old revision of the document!


Сборка шаблона из нескольких файлов и файл functions.php

Иногда бывает удобно разбить шаблон страницы на несколько частей, особенно если в вашей теме есть несколько шаблонов страниц, и вы не хотите использовать один и тот же код несколько раз. Таким файлам присваивается расширение .inc.php

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.

ru/theme/advanced.1380114665.txt.gz · Last modified: 2013/09/25 13:11 by vladislav