Velocity Model and Data Objects in Apache Roller

2 min read

Velocity model and data objects in Apache Roller

There are several standard model and data objects you can use in Apache Roller to access your weblog’s data. Some of the most widely used are $config, $model, $url, $utils, $weblog, $weblogCategory, and $weblogPage. In the following exercise, you’ll get to work with the $config object.

The $config object

This model is used to access Roller’s site-wide configuration parameters, such as the e-mail address of Roller’s administrator, the name of the Roller site, and so on.

Time for action – properties of the $config model object

The following exercise will show you how to use some properties of the $config model object inside your custom template:

  1. Go to your custom template editing page, and replace the six lines of code below the <body><html> line with the following lines:
    Welcome to my blog, <b>$model.weblog.name</b> --> <i>$config.
    siteDescription</i> </br>
    I'm using Apache Roller Version <b>$config.rollerVersion</b> </br>
    You can e-mail me at <b>$config.siteEmail</b> if you run into any
    problems in this site. </br>
    This is my first template </br>
    My weblog's absolute URL is: <b>$url.absoluteSite</b> </br>
    </br>
  2. The entire code of your template should look like the following screenshot (the code you have to change is highlighted):

  3. Save your changes and click on your template’s [launch] link to open a new tab in your web browser and see the results:

  4. Close the results tab if you like, but leave the Frontpage: Templates window open for the next exercise.

What just happened?

The following table summarizes the $config object properties you learned to use in the previous exercise, along with their value:

Property

Definition

Value

$config.siteDescription

Shows your site’s description.

My First Installation of Apache Roller

$config.rollerVersion

Shows the Apache Roller version used.

4.0.1

$config.siteEmail

Shows the site administrator’s email.

alromeromx@gmail.com

You can find all $config parameters under Roller’s Server Admin tab:

The $model, $category, and $entry objects

These objects are used to access all the data for a specific weblog: weblog entries, categories, comments, among others.

Packt

Share
Published by
Packt

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago