What's the index.php file for?
The index file is the container that holds your theme content together. It has this structure:
- File Comments
- Content
--- Top
------ Breadcrumbs
------ User Tabs
------ 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:
PHP Code:
/**
* 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
PHP Code:
$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.
Header
Plugins use the following hook to run code before the header is displayed, or even replace the header completely.
PHP Code:
$result = $h->pluginHook('theme_index_header');
if (!$result) {
$h->displayTemplate('header');
}
Breadcrumbs, User Tabs, Filter Tabs
Plugin hooks are used here to add breadcrumbs, user tabs, filter 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.
PHP Code:
$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.
PHP Code:
$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.
PHP Code:
$result = $h->pluginHook('theme_index_footer');
if (!$result) {
$h->displayTemplate('footer');
}
Bookmarks