Pixaria Gallery includes and is built on a powerful and flexible open source template engine for PHP called Smarty. The engine itself is an object oriented PHP library that enables powerful abstraction between PHP and look and feel (HTML/CSS etc).
Smarty has the great advantage that it separates all application logic (PHP) from design elements (HTML). In many other scripts, HTML is mixed up with PHP code and this makes editing the look and feel of the site difficult, especially for people with no knowledge of PHP.
The Smarty template engine enables me to provide users with simple template files for the look and feel of Pixaria so that no one needs to get their hands dirty with PHP unless they want to. In most cases, editing Smarty files with new or modified HTML is simple but there are a few things to be aware of particularly with respect to using curly brackets { } in your template files as these are used internally by Smarty.
Errors in Smarty syntax will result in pages not loading correctly and the most common cause of this is including JavaScript or CSS style code into your HTML templates without enclosing it in {literal}{/literal} Smarty tags.
Fortunately there are easy solutions to all these concerns and details can be found in the excellent tutorials on Smarty available at Smarty.net. If you have some basic HTML/programming experience, picking up the basics of Smarty is fairly easy and it won't be long before you'll wonder how you managed without it!
Customising Pixaria by editing Smarty templates is a fairly simple process but it helps to have an understanding of come basic PHP concepts like arrays and variables. The Smarty documentation is excellent and provides lots of examples that will help you get the most out of Pixaria.
Before a page of content is displayed by Pixaria, all the information needed to output that page is passed into Smarty as a set of PHP variables and arrays. What happens next is that Smarty gets the template file for the page it's about to generate and inserts the variables required by the template into the appropriate places in the template file before sending the finished page to the web browser.
Each page in Pixaria has a separate template and takes different variables so if you're going to make customisations to a template, you will need to know which variables Pixaria is sending to Smarty for that page. Fortunately, it's easy to list all the data which Smarty has access to for each template by simply inserting the code {debug} into the template file. When the page is next loaded, the web browser will open a popup window listing all the data which can be accessed by the template file for that page (ensure pop-up blocking is off if you want to try this).
The popup window you get by inserting the {debug} tag lists all the information that is given to the Smarty template at the time the HTML output is generated. To display any of these variables in your customised template, all you have to do is insert the variable you want to use (including the dollar sign) into your template enclosed in curly braces, for example: {$page_title}.
Some variables used by Smarty are more complex than a simple piece of text such as a page title or image name. PHP and Smarty are able to store lists of information in a special type of variable called an array. Arrays are lists of multiple variables which can be references and displayed separately from one another.
An example where this is used is the Pixaria gallery thumbnail view. Each image file name, date, width, height, URL, title, caption etc. in those pages is stored as a separate item in a separate array. When the template is processed, Smarty loops through each item in the array generating one thumbnail after another from the items in each array until the entire set of thumbnail image data has been processed.
To access items in an array, you can use the array name e.g. $img_icon_path and the number of the item in the array you want to access (starting with 0). So if you have an array of icon thumbnail paths and you want to display the second item in the array, you would use the Smarty tag {$img_icon_path.1}.
To loop through an array one item at a time as we do with the thumbnail views, you need to use a more complex technique called a section loop. The Smarty documentation has lots more information about how this works.
Created: 2006-05-10 11:24:18
Last edited: 2006-09-14 12:31:18
You can search the Pixaria Gallery user manual by entering keywords here. Keep your search simple for the best results.