Templates

Latest 4 revisions

There are lots of templates available in UCM (see Settings > Templates)

If you are trying to find a template and it doesn’t exist, try sending an email or generating an invoice. Some templates do not appear in the system until after the first time they are used (e.g. if the invoice_print template doesn’t exist, first try to print an invoice and the default template will be created ready for editing).

Here are some hints and tips for editing templates:

  • If you make a mistake, scroll down and hit the “restore default” button. This will clear the template and allow it to be re-loaded with defaults next time UCM tries to use that template.
  • To use translatable strings in the template please use this format: {l:Some Word Here} – these words will be translated into the users local language when displayed on the screen.
  • Scroll down on the template page to see all available template tags that have been used in this template in the past.

Conditional Statements (if/else)

You can perform basic conditional statements within templates based on the values of certain tags. For example

{if:TAG=0} The TAG value was 0 {else} The TAG value was not 0 {endif:TAG=0}

An example of this is in the invoice_print template, you can display a message saying “Invoice Paid” if the invoice has been paid, like so:

{if:IS_INVOICE_PAID} Thank you for payment on this invoice {endif:IS_INVOICE_PAID}

Another example is in the quote_external template, showing if a Quote has been approved or not:

Quote Status: <strong>{if:DATE_APPROVED}Accepted on {DATE_APPROVED}{else}Pending{endif:DATE_APPROVED}</strong>

There is also basic support for nested elseif statement liks this:

{if:TAG=0} The TAG value was 0 {elseif:TAG=1} The TAG value was 1 {else} The TAG value was not 1 or 0 {endif:TAG=0}

Note: {if:TAG} will return true if the string length is greater than 0. So if TAG is “0” then {if:TAG} will return true. So you need to use {if:TAG=0}{else} TAG is not 0 {endif:TAG=0} if checking for a non-0 value.

Number Field Arithmetic in Templates

Template tags now support + – and * arithmetic, here is an example that is used in the “external_invoice” template:

Total: {TOTAL_AMOUNT_DUE} <br>
+10: {TOTAL_AMOUNT_DUE+10} <br>
10%: {TOTAL_AMOUNT_DUE*0.10} <br>
50%: {TOTAL_AMOUNT_DUE*0.50} <br>
-50: {TOTAL_AMOUNT_DUE-50} <br>

This produces the following output:

Total: $100.00 EUR 
+10: $110 EUR 
10%: $10 EUR 
50%: $50 EUR 
-50: $50 EUR

 

And for example, in the “quote_pdf” template you can use these tags:

{TOTAL_AMOUNT}
{TOTAL_AMOUNT*0.10}
{TOTAL_AMOUNT*0.45}
{TOTAL_AMOUNT*0.45}
{currency:TOTAL_AMOUNT}
{currency:TOTAL_AMOUNT*0.10}
{currency:TOTAL_AMOUNT*0.45}
{currency:TOTAL_AMOUNT*0.45}

which gives this output:

85
8.5
38.25
38.25
$85.00
$8.50
$38.25
$38.25

Date Field Arithmetic in Templates

  • For date fields you can increase or decrease the number of days, months or years.
    Example: {DUE_DATE+2m} will add two months onto the “DUE_DATE” value and output that in the template.
    Example: {DUE_DATE-1d}  (minus one day from due_date)
    Example: {DUE_DATE+1y}  (plus one year from due_date)
  • For date fields you can also choose to output just a portion of the date, such as the day, the month or the year.
    You can output something like “Payment is due in February” by using the template tag: {DUE_DATE-F}
    You can output something like “This Quote was approved on 2nd Jan 2015” by using the template tags: {DATE_APPROVED-d}{DATE_APPROVED-S} {DATE_APPROVED-M} {DATE_APPROVED-Y}
    The possible values after the – character are ymdYMDjlSWFn and their details are listed here: http://php.net/manual/en/function.date.php
  • The template tags {DAY} {MONTH} and {YEAR} will always be the current date at the time the page is generated

Email Templates: Current User From Name, Email, etc..

  • You can add details of the current user to some email templates (such as the email_template_default, invoice_email_due and quote_email templates)
  • Simply open up the template ( from Settings > Templates ) and add this code at the bottom:
{if:CURRENT_USER}
From {CURRENT_FIRST_NAME} {CURRENT_LAST_NAME}
Email: {CURRENT_EMAIL}
{else}
From the Team
{endif:CURRENT_USER}
  • This also works with user extra fields (if an extra field is called “Staff Position” it will be available in email templates as CURRENT_STAFF POSITION )