Overview of page templates
From pixyWiki
Each website is defined by a set of page templates, which you can edit to customize the content, layout and appearance of your website.
Page templates
When you create a new pixyBlog website you must pick a theme to define the new websites appearance and layout. A theme is just a small set of templates, where each template contains HTML code, template language expressions and macros.
What's a template? A template for an HTML web page is simply an HTML web page with some Velocity code embedded inside. For example, this is a valid pixyBlog template, with one Velocity expression:
<html> <body> My blog is named $model.weblog.name </body> </html>
The string $model.weblog.name is a template language expression and when pixyBlog displays the template, that expression will be replaced with the name of the website.
Note that $model is something special. pixyBlog makes a set of objects, known as models, available to page templates. In the example above, we see only the $model object, but here are others. You'll learn more about models in Using models, objects and macros and Model Object Reference provides a complete reference.
The Velocity template language
The simple template language that we use inside pixyBlog page templates is called Velocity. It's designed to be simple and easy for even non-programmers, but it's also a simple programming language. You can set variables, use if-else conditional logic and create loops.
For example, this pixyBlog page template will list the galleries available in your website except for the one named Landscape:
<html> <body> My blog is named $model.weblog.name. These are my galleries:<br> #foreach ($gal in $model.weblog.galleries) #if ($gal.name != "Landscape") $gal.name<br> #end #end </body> </html>
Velocity also supports the concepts of macros. A macro is essentially a Velocity method call. We use them in pixyBlog to generate HTML. For example, as illustrated below, to display a bookmark folder you first retrieve if from the website and second pass it to the #showBookmarkLinksList() macro to display it as an HTML <ul> list.
<html>
<body>
<h2>Blogroll</h2>
#set($rootFolder = $model.weblog.getBookmarkFolder("/"))
#showBookmarkLinksList($rootFolder false false)
</body>
</html>
You'll learn more about macros in Using models, objects and macros and Macro Reference, they provide a complete reference to the standard pixyBlog macros. If you want more information on Velocity here are links to the User and Reference guides:
- http://jakarta.apache.org/velocity/docs/user-guide.html
- http://jakarta.apache.org/velocity/docs/vtl-reference-guide.html
Now that we've covered the basic concepts of page templates and the Velocity template language, let's dig into the details of editing and creating page templates.

