Tags are special texts in form $(. . .) which are replaced by planyo with some meaningful content. Every template is aware of the context of:
- a single reservation (see Q204 for the list), examples: email notification, invoice template, reservation details template
- a single resource (see Q205 for the list), examples: resource details template, search results template (the inner code displayed for each result returned by the search)
- a single planyo site (see Q206 for the list), examples: shopping cart template, resource list (outer template which provides the general information about the site)
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).
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 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)
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):
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.