Editing Templates

Layout, Customising
 
Jomres uses the patTemplate library almost exclusively for constructing output (there are exceptions, such as the availability/dashboard calendars and the tabbed options). 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 Editing feature in the administrator area of Jomres. These changes are saved to the database, meaning that your changes will not be overwritten when you upgrade.
 
 
Templates are called, as needed, depending on the screen you're viewing. Sometimes this is just one template, for example when you're viewing a list of properties (list_properties.html). Other times it can be many templates, for example the view property page can have up to 5 if slideshows and tariffs are shown inline. (property_header, property_details, slideshow.html ,show_tariffs.html & show_rooms.html. Also, it depends on your property configuration. If your property is an SRP (single room property) then instead of the rooms list you'll see the availability calendar.
 
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">
<tr>
  <td>
  <table class="innerwrapper">
      <tr class="roomslist_header">
          <td>{HEADER_IMAGEHEADER}</td>
          <td>{HEADER_ROOMNUMBER}</td>
          ...
      </tr>
      <patTemplate:tmpl name="room_details">
      <tr  class="roomslist_content">
          <td><img src=... nd();"></td>
          <td>{ROOMNUMBER}</td>
          ...  
      </tr>
      </patTemplate:tmpl>
  </table>
  </td>
</tr>
</table>
</patTemplate:tmpl>
 
(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. The smoking and guest numbers can be switched off by, respectively, switching the smoking option off in the property configuration and removing (or unpublishing) any guest types you have, but it's not recommended that you actually try to remove them from the form itself.
 
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 and set "Dump Template Vars" to "Yes". This will use patTemplates built in dump feature. You can then analyse this dumped data (by viewing the page in question) to see if the required output is available to your template file. Not all templates support this programatically, if the feature was available to all templates then you would find the page unreadable, therefore we've only made it available to the pages that most people want to change.
 
What about if it's not there?
 
Then you're going to need to get your hands dirty by digging into PHP, which is beyond the scope of this guide.
 
 
 
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 or the input in the administrator area where you've done the template editing. 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 editing feature, then all you need to do is use the editing feature again and click on the name of the template as if to edit it as normal. Then, use the wastepaper/trash icon to delete it. This will remove the template's data from the customised templates table. When you next go to edit it Jomres will see that there is no record for the template in that table and import the unaltered template from the file in the /jomres/templates/jomres/frontend directory so that you can start afresh.
 
 
 
 
This document is copyright Vince Wooll/Woollyinwales IT, 2011. All rights reserved.