Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,090 of 9,090 pages
About the help in other languages
All help pages

Custom edit templates

Give one content class its own edit form on the public site with an override of content/edit.tpl - the override rule, the variables the edit template receives, the form fields and buttons it must keep, and a short…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/templates/custom-edit-templates.md

On this page

Custom edit templates

This page is for designers who want a simpler edit form on the public site for one class, for example a comment form with three fields instead of the general form with its side panel. The administration keeps its own form; the change applies to the siteaccess whose override settings you change.

Contents

The override rule

The edit view renders content/edit.tpl. An override rule in the public siteaccess replaces it for one class:

# settings/siteaccess/<public siteaccess>/override.ini.append.php
[edit_comment]
Source=content/edit.tpl
MatchFile=edit/comment.tpl
Subdir=templates
Match[class_identifier]=comment

The file then lives in your design at override/templates/edit/comment.tpl. Besides class_identifier, the edit view offers the keys object, class, remote_id, class_group, section, section_identifier, and parent_class / parent_class_identifier (the class of the parent of the main location), so a form can also be chosen by place.

What the edit template receives

VariableHolds
$objectthe object being edited
$classits content class
$edit_versionthe number of the draft
$edit_languagethe language code of the draft
$content_attributesthe attributes of the draft, in class order
$content_attributes_data_mapthe same, keyed by attribute identifier
$attribute_basethe prefix of the attribute field names, to pass on to attribute_edit_gui

{attribute_edit_gui attribute=...} prints the input of one attribute with the edit template of its datatype, so the form stays correct for text, images, relations and every other type.

What the form must keep

  • The action address. The form posts back to the edit view of this draft: content/edit/<object ID>/<version>/<language>, built as in the example below (the language part is left out when $edit_language is empty).
  • enctype="multipart/form-data" when any attribute takes a file.
  • The validation messages. Include design:content/edit_validation.tpl, so a refused field is explained.
  • The buttons by their names:
Button nameDoes
PublishButtonpublishes the draft
StoreButtonstores the draft and keeps the form open
DiscardButtonthrows the draft away
  • The redirection fields. Include design:content/edit_redirection.tpl to carry RedirectURIAfterPublish and RedirectIfDiscarded from the session into the form, or set them yourself as hidden fields.

An example

{* override/templates/edit/comment.tpl *}
<form class="comment-edit" enctype="multipart/form-data" method="post"
      action={concat( 'content/edit/', $object.id, '/', $edit_version, '/', $edit_language|not|choose( concat( $edit_language, '/' ), '' ) )|ezurl}>

    <h2>{'Write a comment'|i18n( 'design/mysite/comment' )}</h2>

    {include uri='design:content/edit_validation.tpl'}

    {foreach array( 'subject', 'author', 'message' ) as $identifier}
        {def $attribute = $content_attributes_data_map[$identifier]}
        <div class="form-field">
            <label>{$attribute.contentclass_attribute.name|wash}</label>
            {attribute_edit_gui attribute_base=$attribute_base attribute=$attribute}
        </div>
        {undef $attribute}
    {/foreach}

    <div class="form-actions">
        <button type="submit" name="PublishButton" value="1">{'Publish comment'|i18n( 'design/mysite/comment' )}</button>
        <button type="submit" name="DiscardButton" value="1">{'Cancel'|i18n( 'design/mysite/comment' )}</button>
    </div>

    {include uri='design:content/edit_redirection.tpl'}
</form>

To send the user back to the article after publishing, put RedirectURIAfterPublish into the form that creates the comment (Edit, remove and create buttons on the site): the value travels with the draft.

Things to keep in mind

  • Leave out only what may stay as it is. The shipped datatypes read only the fields that are sent, so an attribute you do not print keeps its value, or stays empty on a new object. A required attribute that is left out is not checked either; print every required attribute.
  • Translations. An attribute with translation disabled shows its value instead of an input when the user edits a translation; the general content/edit_attribute.tpl handles that case, and you can include it instead of a loop of your own.
  • Check the result in every language the class is edited in, and with a user who has only the rights a visitor who writes comments has.
  • Clear the template override cache after adding the rule and the new file, or the general form keeps appearing (Template compilation and cache).

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.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x