Custom tags templates
This page is for designers who give editors extra building blocks inside rich text: a fact box, a quote, a call-out, a formula. A custom tag is a named tag in the XML; it is rendered by a template named after it.
Contents
Declaring a custom tag
settings/content.ini [CustomTagSettings] lists the tags; the kernel ships factbox, quote, strike, sub, sup
(strike, sub and sup with IsInline[...]=true). A theme adds its own in its content.ini.append.php:
[CustomTagSettings]
AvailableCustomTags[]=callout
IsInline[callout]=false
[callout]
CustomAttributes[]
CustomAttributes[]=kindDeclare custom tags in settings that every siteaccess reads (the extension's global settings), not only the public siteaccess: otherwise the administration's editor drops tags it does not know when content is saved. The starter theme keeps its custom tags global for exactly this reason (its README).
Its template
The output handler uses the tag's name as the template name (initHandlerCustom in
kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php; only plain names are allowed):
{* design/mytheme/templates/content/datatype/view/ezxmltags/callout.tpl *}
<aside class="callout callout-first_set( $kind, 'note' )|wash">
$content
</aside>Provide the template in a design every siteaccess reaches (for example your extension's design/standard), so the
administration's preview can draw it too; the starter theme ships plain renderings of its tags in design/standard/.
Custom attributes
Each name in CustomAttributes[] becomes a variable of the template ($kind above). Wash attribute values; they are
editor input. Give every attribute a sensible default with first_set.
Rules
- Inline tags (
IsInline) produce inline markup only (<span>,<sub>,<s>). - No
style=""built from attributes: map an attribute to a class instead. - Semantic elements:
<aside>for a fact box,<blockquote>for a quote,<s>for strike.
Related pages
- Rich text templates
- Designs and siteaccesses
- 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.