Template structure - adampatterson/Tentacle GitHub Wiki

There are no template engines like "Smarty", or "Twig".

Template engines an extra layer of complexity and limit your ability to use native languages.

Required files

  • index.php
  • template-blog.php
  • type-post.php
  • style.css

404.php

This is the standard 404 error page, No data is passed to this page by default.

functions.php

Any custom functions are located in this file, The file is only loaded on the frontend of the site.

screenshot.png

A thumbnail of the theme, used in the admin settings.

bundles

If you want to take advantage of simple asset management it is possible to load asset files through the theme::part() function.

eg.

Call theme::part( 'header',array( ... 'assets'=>'default') ); from a page template or post type. Include more than one file like so default,extra,file each name should reflect a file in the bundles folder without the .php extension.

At a minimum the default.php file should be included with every theme.

The part must include the following code in order to render the assets assets::render( $assets );

style.css

Place the following comment block at the top of your style.css file, in order to display information in the admin settings appearance page:

/*
Name: Default Tentacle Theme
URI: http://tcms.me/
Description: This is the Tentacle default theme.
Author: Tentacle
Version: 1.0
Require: 1.0
License: GNU General Public License
License URI: license.txt
*/

Parts

To load a part you can call theme::part( 'name' ); from any file, including other parts. Parts can accept an array of data theme::part( 'name', array('title'=>'My Home Page', 'assets'=>'default'))

This will make $title and $assets available in your part.

Objects and Arrays can also be passed to parts array('array_data'=>$array)

Some common parts would include header, footer, and sidebar

  • part-header.php
  • part-footer.php
  • part-sidebar.php

To help keep your theme organized you can keep your partials in a folder like this theme::part( 'partials/name' );.

Template

The following comment block will set Template meta data.

/*
Name: Contact
URI: http://tcms.me/
Description: This is the Tentacle default theme.
Author: Tentacle
Version: 1.0
License: GNU General Public License
License URI: license.txt
*/

Name: is required in order to have the Template file show up under Page Templates, The name of the template files does not matter but to keep things tidy it is recommended to name your files template-#####.php

Types

Unlike Templates Types need to be named type-#####.php, this is to prevent name conflicts and also helps to keep your files tidy.

The following comment block will set the post type name in the admin section

/*
Type: Post
*/

Post types are used to display different post formats, You might want to display an image differently than you would a text based post.