Part of the EllisLab Network

Blog & News

Lisa Wess
Director of Community Services

Building a Bug Tracker: Setting up the Templates

So, it’s time to dig in a bit more and get further with the Bug Tracker.  Please remember that you can always find the series Table of Contents on the Building a Bug Tracker page.

Today we’re going to set up our template group and variables.  Before we begin, you might like to take a few minutes to add a few entries to your bug tracker weblog. Have fun with it, you’ll be working with this data throughout the rest of the series.

Shall we jump right into the next step?

Part of the infrastructure that we didn’t set up in the first article was the templates.  We’ll need to do that now.  In your Control Panel, Head over to Templates and Create a new Template Group.  Let’s call it bug_tracker.  That means our first segment will always be bug_tracker.  You will note also that this is the short name of our weblog.  I find that this naming convention is a handy way to follow the relationships that I set up from weblog to template group.

Before we begin to actually build out our templates, we do know that we’re going to need some variables to call our weblog and template group in several places throughout those templates.  There are several ways that we could set this up: The Fresh Variables module, Dynamically Assigned Global Variables, and path.php global variables.

For this tutorial, I’m going to use path.php global variables.  The reason for this is that it requires no extra module installation, and is set in one place (path.php) rather than at the top of each template, as with assigned variables.

So, FTP to your site, make a backup of path.php, then open it in your favorite HTML editor.  Let’s define two new path.php global variables:

"bug_tracker_weblog" => "bug_tracker",
"bug_tracker_template_group" => "bug_tracker",

Now, if you later want to rename your bug_tracker weblog short-name or template group, you will need to do so in only one location - in path.php.

Don’t forget to save and re-upload path.php.

What this means is that anywhere in our templates where we need to reference the weblog, we’ll simply use:

{bug_tracker_weblog}

and anywhere we need to reference the template group, we’ll use:

{bug_tracker_template_group}

This is a fairly simplified use of path.php global variables, but I include it here because it’s very handy, and highlights a neat trick for future use on your own sites.

You could also just use one path.php global variable, as the template group and weblog short name are the same; however, using two variables will give you more customization flexibility outside of this tutorial, as well as more readability in your templates.

We now have our template group and main variables set up, and in the next article, will be ready to start building out our templates.  You will need data in your weblog to see the results from that point forward, so please do add some entries before next week’s article!