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.

If you liked this article, please share it on Digg, Stumble Upon or del.icio.us. Thank you.


Spread the word:

Tags: , ,

Technorati Tags: , ,


4 Responses to “How to include an HTML file in Smarty or Gallery 2”

  1. Gadget Newz says:

    [...] How to include an HTML file in Smarty or Gallery 2 [...]

  2. buy says:

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

  3. vemmakp says:

    Very interesting information! Thank you for this blog!

  4. gry says:

    Very Interesting Blog! Thank You For This Post!

Leave a Reply