FAQ Q256: How to use tags to customize email messages and templates?

Tag context

Tags are special texts in form $(. . .) which are replaced by planyo with some meaningful content. Every template is aware of the context of:

The context of a template decides which tags can be used. If the reservation context is known, then of course also the resource context is known (a reservation is always tied to a single resource), and the site context is always known. For example, all email notifications can use all context-specific tags but the resource list template can't use reservation-specific tags. Whenever you define a template, in the description you'll see the tags which can be used. Sometimes special tags are also allowed, specific to given template. All templates can also use universal tags (see Q221 for the list) which are very general, not even specific to a given planyo site. They're used to provide other types of context (e.g. to print a QR code or 2d barcode or to format a price in a nice way or do math calculations).

Nested tags

Most tags are simple tags, e.g. $(current_website) will be replaced which the website where the template is being displayed on. Other tags can be parameterised, for example the $(round:XXX) tag rounds a number to the nearest whole number, e.g. $(round:4.44) is replaced with 4. This tag really makes sense only when other tags are nested inside it, for example $(round:$(price_quoted)) gives you the reservation price rounded to the nearest whole number. Tags can be also nested many times, e.g. $(format_price:$(round:$(price_quoted))) will also format this number in a way specific to prices, e.g. USD 3,000.00 instead of USD 3000

Conditional tags

Conditional tags are extremely useful because you can output code conditionally. For example, if the rental is coming up very soon you might want to add a highlighted text informing about some action which is urgent. Another place where conditional tags are very useful are email notifications. Planyo never sends out emails with empty body. This means that if the entire email body is placed inside a condition, you can send a specific notification only when your condition is met. Otherwise the email won't be sent. Conditional tags are discussed in detail in Q207, here's an example:
$(if) $(days_until_rental) less than 3 $(then) NOTE: LESS THAN 3 DAYS REMAIN UNTIL YOUR ARRIVAL $(else) You still have $(days_until_rental) days before your arrival $(endif)

Iterators

Tags mainly having the reservation context can use a number of iterators -- tags which repeat embedded code a number of times. This is useful if you'd like to do things such as show all images from a resource, or list all reservations included in the same shopping cart, or list all additional products reserved, or list all payments made for the reservation so far. Here's an example (see Q204 for a detailed explanation):

$(foreach:$(reservation_payment_count))
$(reservation_payment_mode:$(it)) $(reservation_payment_amount:$(it))
$(endfor)

The $(foreach:x) tag simply expects x to be a number and the code between $(foreach) and $(endfor) will be repeated x times. In the example above, it will be repeated as many times as number of payments made. The code embedded inside can then use the special $(it) tag which can tell you which iteration is being processed. E.g. in case of 3 payments, this will be 1, then 2, then 3. So $(reservation_payment_amount:$(it)) becomes the amount of the first, then second, then third payment.

Tag playground

The tag playground lets you quickly test code snippets which include tags in the context of a specific reservation, resource or in the general site context. Note that the context you should use depends on the template you'll be inserting the code snippet into. E.g. the resource details template can only use site and resource context while the reservation details or email templates also work within the context of a single reservation.
Back to Frequently Asked Questions