In essence, a theme is a set of templates, and a template is composed of HTML and Velocity code. You can make your own templates to access your weblog’s data and show this to your visitors in any way you want.
In Apache Roller, you can create, edit, or delete templates via the Frontpage: Templates page. Let’s see how to use this wonderful tool to create and edit your own templates!
In this exercise, you’ll learn to create and edit your first custom template via Roller’s admin interface:
<html>
<body>
Welcome to my blog, <b>$model.weblog.name</b> </br>
This is my first template </br>
My weblog's absolute URL is: <b>$url.absoluteSite</b> </br>
</body>
</html>
This is shown in the following screenshot:
Now you know how to create your own templates! Although the previous example is very simple, you can use it as a starting point to create very complex templates. As I said before, templates are composed of HTML and Velocity code.
The template we wrote in the previous exercise uses a few basic HTML elements, or tags:
HTML Tag | Definition | Tip |
<html> , </html> | Defines the start/end of an HTML document. | You must write this tags at the beginning/end of each Roller template. |
<body>, </body> | Defines the start/end of an HTML document’s body. | All the code you will write for your templates must go between the <body> and </body> tags. |
<b>, </b> | Shows text in bold. | Example: <b>Hello</b> shows up as Hello |
</br> | Indicates a line break. | Example: Hello</br>World shows up as Hello World |
Also, there are some elements from the Velocity Template Language, along with an example from the previous exercise:
Velocity Element | Definition | Example |
$model.weblog.name | Shows the name of your weblog. | <b>$model.weblog.name</b> shows up as Ibacsoft’s Weblog |
$url.absoluteSite | Shows the absolute URL of your weblog | <b>$url.absoluteSite</b> shows up as http://alromero.no-ip.org/roller |
These are just some of the basic HTML tags and Velocity elements you’ll learn to use for your templates. In the following sections, we’ll see some more, along with elements from the Velocity Template Language.
All templates in Roller use HTML tags, along with Velocity code. In the next subsections, you’ll learn about some of the most widely used Velocity elements in your Roller templates.
A macro in Velocity is a set of instructions that generate HTML code based on data from your weblog. They are very helpful when you need to do the same task more than once. In the following exercise, you’ll learn to use some macros included in Roller in order to show your weblog data to your visitors.
Now you will use the Velocity Template Language to show your weblog’s bookmarks (blogroll) in your custom template, along with the most recent entries:
Go to your custom template editing page, and type the following code just above the </body></html> line:
</br>
These are my favorite Web sites: </br>
#set($rootFolder = $model.weblog.getBookmarkFolder("/"))
#showBookmarkLinksList($rootFolder false false)
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…