Hotaru Docs


Make your first plugin

Case Study 1: Hello World

The first ever plugin for Hotaru CMS was, unsurprisingly, Hello World. It's a plugin that does absolutely nothing except display the words "Hello World" on the screen. While the result isn't very impressive, it's a good first step in learning how Hotaru CMS plugins are put together.

There are 5 key steps in making a plugin:

  1. You must have a folder, e.g. hello_world.
  2. You must have a .php file with exactly the same name as the folder.
  3. You must include comments at the top of the file. Here's a list of what's needed and what's optional:

    attribute name description required
    name plugin name yes
    description plugin descripition yes
    version plugin version number yes
    folder plugin folder name yes
    class plugin class name yes
    hooks comma separated list of plugin hooks (all on the same line) yes
    type the kind of plugin, e.g. "avatar" no
    requires for plugin dependencies no
    extends for overriding another plugin no
    author for the plugin author's name no
    authorurl for a link to the author's website no

     * name: Hello World
     * description: Displays "Hello World!"
     * version: 0.1
     * folder: hello_world
     * class: HelloWorld
     * hooks: hello_world
     * You can type notes here
  4. You must wrap your functions in a class that extends the PluginFunctions library, e.g.:
    class HelloWorld
  5. You must have a function with the same name as each hook [1], with $h as the first parameter [2]. For example:
    class HelloWorld
        public function hello_world($h)
            echo "Hello World!";

Plugin Folder

Once that's done, put the plugin folder in Hotaru's content/plugins directory, then go to Admin->Plugin Management and install it.

To see the results, you just need to add this line in your template[3]:

<?php $h->pluginHook('hello_world'); ?>


  1. If you include a plugin hook in the comment block at the top of the file, but don't have a function for it, Hotaru will fall back on the default method in the Hotaru.php under DEFAULT PLUGIN HOOK ACTIONS. If there's no default function either, you'll get an error. You can use this fall-back behavior to your advantage, using it to simplify plugins.
  2. Hotaru passes the global $h object to every plugin hook function. This can then be used to access all of Hotaru's built-in functions.
  3. You don't have to make your own plugin hook. You can use any existing hook just as long as you put the hook name in the comment block and give your function the same name. In the case of Hello World, change the hook and function name to footer, reinstall the plugin and you should see Hello World! displayed in your footer. That's because it's using a built-in plugin hook in footer.php called footer.

You can download the Hello World plugin here.

Case Study 2: Hello World Widget

Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting