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 line with the following lines:
    Welcome to my blog, $model.weblog.name --> $config.
    siteDescription

    I'm using Apache Roller Version $config.rollerVersion
    You can e-mail me at $config.siteEmail if you run into any
    problems in this site.
    This is my first template
    My weblog's absolute URL is: $url.absoluteSite

  2. The entire code of your template should look like the following screenshot (the code you have to change is highlighted):

    Apache Roller 4.0 – Beginner's Guide

  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:

    Apache Roller 4.0 – Beginner's Guide

  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.


Subscribe to the weekly Packt Hub newsletter. We'll send you this year's Skill Up Developer Skills Report.

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here