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

[Docs] Including Template, Language, JavaScript and CSS Files in a Plugin

Discussion in 'Developing Plugins' started by Nick, Jul 21, 2009.

  1. Nick

    Nick Well-Known Member

    In order for users to save their customizations from unwanted overwrites when plugins are upgraded, Hotaru allows them to move files out of a plugin and into their theme, where those files will still work equally well (explained here).

    To use this functionality correctly, please follow these rules:

    1. Put all template files in a folder called "templates".

    Use like this:
    PHP:
    $h->displayTemplate('template_name'); // No file extension


    2. Put all language files in a folder called "languages"
    .

    For a single file, name it pluginname_language.php, e.g. "submit_language.php".

    Language files are automatically included when each plugin function is called.

    Read more about language files here.


    3. Put all css files in a folder called "css".


    For a single css file name plugin_name.css, include them in a header_include function like this:
    PHP:
    $h->includeCss();
    For additional .css files named other_name.css, include each like this:
    PHP:
    $h->includeCss('filename'); // No file extensions


    4. Put all .js files in a folder called "javascript".


    For a single javascript file name plugin_name.js, include them in a header_include function like this:
    PHP:
    $h->include_js();
    For additional .js files named other_name.js, include each like this:
    PHP:
    $h->include_js('filename'); // No file extensions
     
    Last edited: Jan 8, 2010
  2. Nick

    Nick Well-Known Member

    Include CSS and JavaScript Files Automatically

    Hotaru is smart enough to include files for you if they share the same name as the plugin. For example, imagine you have a plugin called OzzleFloppy with a single CSS file and/or a single JavaScript file in their respective folders, like so:

    ozzle_floppy
    --- ozzle_floppy.php
    ------css
    ---------ozzle_floppy.css
    ------javascript
    ---------ozzle_floppy.js

    Because the names of the .css and .js files match the name of your plugin folder, Hotaru can automatically detect them and include those files. All you need to do is make sure you have header_include in your list of plugin hooks at the top of your main plugin file. You don't need to make a header_include function because hotaru will fall back on the default functions in /Hotaru.php and include your files for you.
     

Share This Page