Editing Templates


Layout, Customising


Jomres uses the patTemplate library almost exclusively for constructing output. The reason for this is simple. It is much easier for you as the system admin/designer to modify the look and feel of your site when using templates than when html is embedded in code. Because the template code is used to make it easier for you to edit the look of your site we have refrained from using any of the patTemplate functionality beyond what is used to render html output, so you should find it very easy to edit the code to suit your requirements, however there are a few things you need to know.

The core template files are saved in the folder /jomres/templates/jomres/, however we want to discourage you from editing these files. If you upgrade Jomres you will lose all of your changes to these files, therefore it's better that you use the Template Overrides.


Ok, onto a few questions we get asked from time to time:

In these template files there's stuff between curly braces ( {XXX} ). What are they?

The script passes the stuff within the curly braces to the template; it's the data that's generated by the system. Most of the time it's only shown the once, but sometimes we need to cycle through a list of data, in which case you'll often see code that looks like this:

<patTemplate:tmpl name="room_headers">
<table id="panelwrapper">
   <table class="innerwrapper">
       <tr class="roomslist_header">
       <patTemplate:tmpl name="room_details">
       <tr  class="roomslist_content">
           <td><img src=... nd();"></td>

(Edited to make it more readable)

In this example, there are two sets of rows; one is within the room_headers patTemplate declaration, whereas the other is inside the room_details declaration. The room_details data will be output by patTemplate for as many rooms as there are to display.

Don't worry if you don't understand it all immediately, you'll soon get it when you start experimenting with editing the files.

What can I edit in a template file?

This is a regular question we get asked, and the answer depends on which template you're editing.

If it's the booking form template, then the answer is: not much. You can move things around and hide them inside "divs" that have the same foreground and background colours or HTML's comment tags (<!-- -->) but it isn't recommended that you actually remove anything. Probably the only exception to this rule would be the address input fields; if you've made a field so that it is not required during the booking process then you can convert this to a hidden field in the booking form. You can't remove the input completely because the booking object will still try to update that field if an authorised user selects a guest's name from the Guest Names drop down box, and if the input doesn't exist the JavaScript in the booking form will fail with an error.

If it's any one of the other templates, then you're largely free to run amok with the delete key, but keep backups of the original files in case you go a bit wild and find you're unable to undo what you've done.

I want to show blah in x template. How do I do it?

The first rule to understand when editing templates is, if the data isn't available to the template then you can't show it, however there may be times when the template file you're using has data available to it but it's just not showing it. How do you find out?

The easiest way is to go to the Site Configuration -> Debugging tab and set "Dump Template Vars" to "Yes". This will change how templates are output in the front end, and is a great way of identifying which template file is producing some output. If you hover over the file name, you'll see a list of all elements that are available to that template.

Common issues

I'm seeing multiple sets of output in, for example, the guest's email that confirms that the booking's been placed has effectively two copies in the output, or patTemplate complains that a template doesn't exist.

Most likely you've accidentally pasted two copies of the template's output into the template file. Review what you've changed and make any changes required to resolve the issue.

I've made a complete pig's ear of editing my template and deleted stuff that I need, how do I restore the original so that I can start again?

Assuming you've done the smart thing and used the Jomres template overrides feature, then all you need to do is remove your override version of the html file.

Common Strings

The patTemplate templating system is an old library which is no longer supported or maintained by it's creators. Normally this is a bad thing for most libraries and we'd consider moving over to a new library, but with patTemplate we've decided to not do that, and instead we've added some of our own functionality to the system.

The most obvious of these are the "Common strings", which are strings that we add to every template that's parsed by the patTemplate class, meaning that they don't need to added programatically by the calling script. You can see the strings by visiting the administrator area Jomres Developer Tools area, Common Strings menu option.



If you're a developer who's modifying templates and finds yourself adding strings to every template, you can programatically have your own common strings. Open the file j00005create_misc_common_strings.class.php in the /jomres/core-minicomponents directory to see an example of how we do it. You can create your own 00005 script to perform the same function.



Jomres Manual