PDF and XML templates
A PDF template sets how the programme booklet looks. An XML template delivers the same details as data, for example for a typesetting program.
You write both types in the editor of the export templates in Twig, a language for templates. What applies to all templates is described there.
What fepli makes of the template
- In the template the offers are called
items. - Writes HTML, the language of web pages, one section per offer.
- fepli turns it into pages, with the template’s page size, margins and base font.
- In the template the offers are called
offers. - Writes XML, one entry per offer.
- fepli outputs it as written, once every element is opened and closed correctly.
A PDF template writes HTML, the language of web pages. fepli sets it into the pages of the PDF with the program mPDF. An XML template is output as it is written. fepli only writes the file, though, once the XML is well-formed, meaning every element is opened and closed correctly.
Page and font
Only a PDF template has these settings.
| Field | Meaning | Values | Default |
|---|---|---|---|
| Page size | Size of the page | A4, A5, A6 | A4 |
| Portrait, Landscape | Orientation of the page | Portrait, Landscape | Portrait |
| Margins in mm | Distance from the edge of the page: Top, Right, Bottom, Left | 0 to 40 | 15 |
| Base font | Font of the whole document, from the supplied and the uploaded fonts | Name of a font | Geist |
| Font size | Size of the base font in points (pt) | 6 to 24, in steps of 0.5 | 11 |
Source text and preview
The middle shows the source text of the template with line numbers. Below it, the status bar shows “No errors” or “Line {line}: {message}”; the faulty line is marked red.
On the right you switch between two views:
| View | Content |
|---|---|
| Preview | The result with the first offers of the season that currently has an editing phase. If it has no offers, fepli uses sample offers. A PDF appears with its pages, an XML as text. |
| Variables | The details that can be inserted (Variables). An entry inserts its text at the caret. |
If the template has an error, the preview shows “Preview not possible” with the message and the link Go to line {line}.
Variables
A variable is a placeholder that fepli replaces with a detail of the offer. The PDF template receives the offers as items, the XML template as offers. In the table, list stands for this list.
| Variable | Content | Applies in |
|---|---|---|
list | The offers of the export. The entry inserts a loop for offer in … that repeats for each offer. | PDF, XML |
offer.name | Title | PDF, XML |
offer.number | Offer number | PDF, XML |
offer.teaser | Short description | PDF, XML |
offer.description | Description, prepared as on the website. Embedded HTML and unsafe links are dropped. | PDF, XML |
offer.dates | Dates with begin and end | PDF, XML |
offer.minAge, offer.maxAge | Age from, age to | PDF, XML |
offer.fee | Fee in euros or francs, as set | PDF, XML |
offer.meetingPoint | Meeting point | PDF, XML |
offer.bring | What to bring | PDF, XML |
offer.applyText | Note on applying when this does not run through fepli | PDF, XML |
offer.hosts | Organizers with name | PDF, XML |
offer.categories | Categories with name | PDF, XML |
offer.properties | Own properties with Print in the booklet, with label and value (Settings) | PDF, XML |
edition.name | Season | PDF, XML |
today | Date of the export | PDF, XML |
images | Logos of the organizers with path and dimensions | XML |
<pagebreak /> | New page | |
{PAGENO} / {nbpg} | Page number in header or footer | |
<htmlpagefooter> | Footer on each page | |
var:tenantLogo | Logo of the instance, e.g. <img src="var:tenantLogo" height="18mm" /> | |
loop.index, loop.last | Counter in loops | PDF, XML |
date | Formats a date, e.g. date('d.m.Y') | XML |
<![CDATA[ … ]]> | Text with special characters | XML |
Rules
| Rule | Content |
|---|---|
| Permitted Twig | A template may only use a selection of Twig’s commands. A variable that does not exist is an error. |
| Images and links in the PDF | Their addresses must begin with var:, data: or #. fepli removes every other address. Files of the server never get into the PDF. |
| Fonts in the PDF | font-family names a font from the fonts. |
| Colours for print | cmyk(C, M, Y, K) with values from 0 to 100, e.g. color: cmyk(0, 85, 90, 0). The PDF holds them in CMYK, the preview and the PDF studio show them approximately. Images keep their colours. |
| PDF studio | The PDF studio finds the offers’ pages if the template writes them in a loop over items, one section per offer. |
| Adjustments from the PDF studio | Hold for this template and this offer until one of the two changes (Origin). |
Messages
| Message | Meaning |
|---|---|
| “There is no variable “{name}” here.” | The template uses a variable that does not exist. The list Variables shows the right names. |
| “There is no field “{name}” here.” | The offer has no field of this name. |
| “There is no filter “{name}”.”, “There is no function “{name}”.” | Twig knows no command of this name. |
| “The tag “{name}” is not allowed in export templates.”, also for filters and functions | The command exists, but export templates may not use it. |
| “A block is not closed – is endfor or endif missing?” | A for or if has no end. |
| “The output is not valid XML: {message}” | The result of an XML template is not well-formed. fepli does not write the file. |