Jump to content

Developer Documentation

Adding resources to plugins

Plugins support external resources such as images, javascript files, CSS and templates, should you need to use them.


HTML templates

HTML files will become templates within the core -> global -> plugins group. In other words, you will get the content of the HTML files you create using this code in controllers, where filename is the name of your template file:

\IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' )->filename( ... );

Or the following code from within other templates:

{template="filename" group="plugins" location="global" app="core"}

You should create your files using the extension ".phtml". The first line of the file should be the following tag:

<ips:template parameters="$example1, $example2" />

Replace $example1, $example2 with the names of whatever variables you intend to pass in. It is fine to have no parameters; in that case, the parameters attribute should simply be an empty string. 

After that opening line, the remainder of the file should just be what you want the template contents to be. You can use template logic and template tags. Note that if any of the code in your template causes an exception to be thrown (which could happen if you're using particularly complicated template logic/tags without proper try/catch statements) the contents of the template will be ignored and will return an empty string.


CSS/Javascript files

Any CSS and JavaScript files you create will be compiled with the rest of the CSS and JavaScript automatically, so you do not need to do anything other than create the files. Be sure you create the files, with file extensions, in the appropriate directory within your plugin's own directory.



When your plugin is run, images will be placed in core -> global, in a folder called plugins. In other words, you will render the images you place in the /resources directory by using this code in templates:

<img src='{resource="plugins/example.jpg" app="core" location="global"}'>

You must put all images directly in the /resources directory, do not create subdirectories.

  Report Document

  • Create New...