How to include an HTML file in Smarty or Gallery 2

If you are writing your own Gallery 2 theme, you may need to insert a plain HTML or JavaScript file into the page, without requiring Smarty to process that file. In case you are wondering what is Smarty – it is  the sophisticated template engine that renders Gallery 2’s pages. You can find additional information about Smarty at Smarty’s web site.

The best way to include a static HTML or JavaScript file is to use Smarty’s fetch command:

{fetch file="/webroot/html/includes/header.html"}

This will insert the header file at /webroot/html/includes/header.html, without parsing it by looking for Smarty specific commands. This has the benefit of speeding up the rendering of the page.

Notes about Smarty’s fetch command:

  • It does not accept variables in the value of file= argument.
  • You need to specify the full path of the included file.

4 thoughts on “How to include an HTML file in Smarty or Gallery 2

  1. Pingback: Gadget Newz

  2. buy

    Searching for this for some time now – i guess luck is more advanced than search engines 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *