Rich text templates
This page is for designers who control the markup of rich text: body texts, intros, descriptions. Rich text is stored as
XML; when it is shown, every tag is rendered by a template of its own in content/datatype/view/ezxmltags/
(TemplatesPath in kernel/classes/datatypes/ezxmltext/ezxmloutputhandler.php).
Contents
- The tag templates
- What a tag template receives
- Changing a tag for your design
- Classes editors can choose
- Headings
The tag templates
design/standard/templates/content/datatype/view/ezxmltags/ has, among others: paragraph.tpl, header.tpl,
strong.tpl, emphasize.tpl, link.tpl, anchor.tpl, ul.tpl, ol.tpl, li.tpl, table.tpl, tr.tpl, td.tpl,
th.tpl, literal.tpl, line.tpl, embed.tpl, embed-inline.tpl, and the custom tags factbox.tpl, quote.tpl,
strike.tpl, sub.tpl, sup.tpl.
What a tag template receives
$content: the already rendered inner HTML (print it withoutwash).$classification: the class the editor chose.$alignwhere the tag supports alignment.- tag-specific values:
$href,$title,$targetfor links;$levelfor headings; custom attributes for custom tags.
The shipped paragraph.tpl:
set $classification = cond( and( is_set( $align ), $align ), concat( $classification, ' text-', $align ), $classification )
<pif $classification|trim class="$classification|wash"/if>
if eq( $content|trim(), '' ) else$content/if
</p>Changing a tag for your design
Copy the tag template into your design at the same path, or use an override on
Source=content/datatype/view/ezxmltags/<tag>.tpl (with Match[class_identifier] to limit it to one class). For
example a table wrapped in a scroll container:
{* design/mytheme/templates/content/datatype/view/ezxmltags/table.tpl *}
<div class="table-scroll">
<tableif $classification|trim class="$classification|wash"/if>
$rows
</table>
</div>(Read the original first: each tag receives its own variables; the table template receives the rendered rows.)
The kernel's factbox.tpl still uses the old bgcolor attribute, and table.tpl prints a style="width: ..." when an
editor set a table width: a design for a site with a strict Content Security Policy (style-src 'self') overrides both
with classed elements.
Classes editors can choose
content.ini [<tag>] AvailableClasses[] lists the classes editors may pick for a tag in the online editor, for example:
[paragraph]
AvailableClasses[]=lead
AvailableClasses[]=noteStyle each class in your stylesheet; the paragraph template puts it into class="".
Headings
header.tpl maps rich text levels to HTML: level 1 becomes h2, level 2 h3 ... (the full view's own h1 is the
page title). It also prints eztoc anchors for tables of contents. Keep this mapping, or the page gets two h1.
Related pages
- Custom tags templates
- Embed view
- Datatype view templates
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.