1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Docs] The Hotaru Cycle

Discussion in 'Developing Plugins' started by Nick, Sep 23, 2009.

  1. Nick

    Nick Well-Known Member

    Here's a brief explanation of how Hotaru works:

    The Hotaru Cycle:

    Core index → Theme index → Display template → user action → Core index

    What happens at each stage?

    Core index

    There are 2 entry points in Hotaru, index.php and admin_index.php. Everything goes through one of those files. Let's look at them:

    PHP:
    <?php
    // includes
    require_once('hotaru_settings.php');
    require_once(
    'Hotaru.php');
    $h = new Hotaru();
    $h->start('main'); // or "admin" in admin_index.php
    ?>
    That's it. The settings file is included first and a new $h (Hotaru) object is constructed. The constructor and start method in Hotaru.php* sets up everything and finally displays the index template from your theme folder.

    * The Hotaru class is the engine of your site. It includes a number of files such as class libraries, utility files and third party extensions. It initializes the database and pulls in the settings stored in the database. It sets up Inspekt for input filtering and validation and then checks for a cookie so users can log in. The bulk of Hotaru.php is used for shortcuts to most of the functions in other classes.

    Theme index


    The index.php template file in your theme folder is the skeleton for how your pages are displayed. It includes a header, sidebar and footer. Each section pulls in a relevant template or is otherwise overridden by plugins**, e.g.

    PHP:
    <!-- SIDEBAR -->
    <?php
         
    // plugin hook
         
    $result $h->pluginHook('theme_index_sidebar');
         if (!
    $result) {
             
    $h->displayTemplate('sidebar');
         }                                
    ?>
    Full details on the index.php template can be found here.

    ** This is where the magic happens. Plugins check for parameters passed via links or forms and determine the content to display based on those parameters. If there are no plugins, Hotaru will simply display an empty template.

    Display template

    The index template is displayed, containing a combination of different templates, e.g. sidebar.php.

    User action

    When a user clicks a link or submits a form, Hotaru returns to the beginning of the cycle and rebuilds the page depending on the parameters passed by the link clicked or the form submitted.
     
    Last edited: Jan 6, 2010

Share This Page