Hotaru Docs

 [həʊdɒks]

Themes: A Guide to index.php

The theme index file is the container that holds your theme content together. It has this structure:

  • File Comments
    • Top
      • Breadcrumbs
      • Post Breadcrumbs (as in after breadcrumbs)
      • Filter Tabs
      • Main
      • Sidebar
      • Footer

File Comments

Unlike plugins, the comment block at the top of a theme file serves no other purpose than to inform the reader about the file. Here's a typical comment block:

/**
 * Theme name: default
 * Template name: index.php
 * Template author: Nick Ramsay
 */

CONTENT

There are a number of sections that make up a page's content in the default theme, and you'll see that each of them has a block of php code. That code is used to decide what to show, like this:

Top

$result = $h->pluginHook('theme_index_top');
if (!$result) {
...
}

Plugins use that hook to process code before anything is output to the page. The "if" conditional gives plugin developers the power to override the entire page. If something is returned from the plugin, then the code within the curly brackets will not be used.

Header

Plugins use the following hook to run code before the header is displayed, or even replace the header completely.

$result = $h->pluginHook('theme_index_header');
if (!$result) {
      $h->displayTemplate('header');
}

Breadcrumbs, Post Breadcrumbs, Filter Tabs

Plugin hooks are used here to add breadcrumbs, tabs, or anything else plugin developers desire.

Main

Plugins use the following hook to run code before the main body of the page is displayed, or even replace that section completely.

$result = $h->pluginHook('theme_index_main');
if (!$result) {
      $h->displayTemplate($h->pageName);
}

Sidebar

Plugins use the following hook to run code before the sidebar is displayed, or even replace the sidebar completely.

$result = $h->pluginHook('theme_index_sidebar');
if (!$result) {
      $h->displayTemplate('sidebar');
}

Footer

Plugins use the following hook to run code before the footer is displayed, or just replace the footer completely.

$result = $h->pluginHook('theme_index_footer');
if (!$result) {
      $h->displayTemplate('footer');
}
Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting