Welcome to the OpenCities help centre. Search for what you're after, or browse the categories.
Can't find what you're looking for? Submit a support ticket and we'll be in touch.

Follow

Field Templates

avatar of OpenCities Product Team

OpenCities Product Team

Last updated

This task is for users with the OC Developer role.

All fields have one or more templates that determine how the field's value is displayed on your live site. First, you need to create a field, then your field templates. When you make a field, it will automatically have a default template, and if you're happy with the default, you won't need to create more.

Once your field and its template(s) are ready, you can add that field to a custom content type. You then specify which field template you want to use as you're creating a template for your content type.

Copy and Edit a Field Template

When you create a field, a default template will automatically be created. We strongly recommend you do not change the default template of any field, and you cannot edit the templates for OC Fields. Instead, you should copy the default template and work on this copy or create a new one from scratch. You can create as many templates as you need to.

  1. Go to More > Fields, and select the field you need.
  2. Switch to the Templates tab and select the template you want to copy from the list under Template Name. Or, select Create New to start a completely new template.templates tab.png
  3. Scroll to the bottom of the page and, from the drop-down menu, select the field you want to copy the template to. You can only copy templates to fields of the same type, and if you want to copy the template into the same field, select the current field.
  4. Select Copy, then select Cancel to go back to the template list. copy field template.png
  5. Choose the new template named Copy of [template name] from the list, and you're ready to start editing.
  6. Complete the different elements of the template, then select Save Template and Save the field.Edit field template.png

Your field and field templates are now ready to use on custom content types and content type templates.

Field Template Elements

There are five parts for most templates and six for date fields. Each component can have HTML, text, or references to other fields. When the markup is generated, the different template parts are combined like this:

The template parts are put together so that the template header is at the top, followed by the template text/alternate text (which displayes once or repeats multiple times for multi value fields), followed by the template footer. Alternatively, the empty template will be displayed.

Use the following information to fill out your template:

  • Template name: A unique name for your template.
  • Template header text: Header text is displayed once at the top when the field has a value.
  • Template text: The content for the field. You can use the Property drop-down menu to Insert field options into the Template text. This text displays once for single-value fields, such as the Textbox, Textarea, WYSIWYG, Drop Down List, and Radio button List. It will display multiple times for multi-value fields, such as the Check box List or List Hyperlink. For date fields, template text is used for single dates, multi-dates, and recurring dates.
  • Alternate template (date fields only): The Alternate template is only used for date fields when the value is entered as a time span. This allows you to have alternate templates for the start date, end date, or different dates.
  • Template footer text: Footer text is displayed once at the bottom when the field has value.
  • Empty template text: Empty template text is rendered once when the field doesn’t have a value. The header, footer, template text, and alternate template will not be displayed when this is shown.

What Else?

 

 

Was this article helpful?
0 out of 1 found this helpful