Results 1 to 1 of 1

Thread: Themes: A Guide to index.php

  1. #1
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,869
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Post Themes: A Guide to index.php

    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');

    Last edited by Nick; 01-06-2010 at 01:22 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •