Editable content
Mark the parts of the HTML that the user can edit, repeat, remove or fill with widgets.
On this page
In the <body> of a widget you mark the parts that the user can change in the visual editor. You mark them with classes that start with CMS_. CMS removes these classes from the public page.
This widget, Questions, has two items. The user can edit each question and answer, duplicate an item and remove it:
<script total>
exports.id = 'faq';
exports.name = 'Questions';
exports.author = 'Jane Doe';
exports.version = '1';
exports.config = { open: false };
</script>
<style>
.CLASS-item { border-bottom: 1px solid #E0E0E0; padding: 10px 0; }
.CLASS-question { font-weight: bold; cursor: pointer; }
.CLASS-answer { display: none; padding-top: 5px; color: #555; }
.CLASS-open .CLASS-answer { display: block; }
.CMS_preview .CLASS-answer { display: block; }
</style>
<settings>
<div class="padding">
<ui-component name="configuration" path="?" class="invisible">
<script type="text/plain">
[
{
id: 'open',
name: 'Open the first answer',
type: 'boolean'
}
]
</script>
</ui-component>
</div>
<script>
exports.save = function(config, el) {
el.find('.CLASS-item').rclass('CLASS-open').first().tclass('CLASS-open', config.open);
};
</script>
</settings>
<body>
<div class="CLASS-item CMS_repeat CMS_remove">
<div class="CLASS-question CMS_edit">What are your opening hours?</div>
<div class="CLASS-answer CMS_edit CMS_multiline">We are open from Monday to Friday.</div>
</div>
<div class="CLASS-item CMS_repeat CMS_remove">
<div class="CLASS-question CMS_edit">Where are you?</div>
<div class="CLASS-answer CMS_edit CMS_multiline">In the city centre, next to the station.</div>
</div>
</body>
<script>
$(document).on('click', '.CLASS-question', function() {
$(this).parent().tclass('CLASS-open');
});
</script>Edit text, images, links and icons
Add CMS_edit to an element to enable Edit in the floating panel:
- Text: the user types into the element.
Enterends the editing, unless the element also hasCMS_multiline, whereEnteradds a line break. - Image (
img): the user uploads or picks a picture. Withdata-cms-widthanddata-cms-height, the editor shows a grey placeholder of that size and opens a crop window, so every picture gets that size. - Icon (an element with the class
ti): the user picks another icon. - Link (
a): Change link changes its address and target.
CMS_attribute enables Change attributes, which opens the attributes editor for classes, styles and other attributes. Elements with CMS_edit have it too.
CMS_unwrap keeps the element in the editor and removes its tag on the public page, leaving only its content. Use it for a span that exists only to be editable.
Repeat and remove
CMS_repeatenables Duplicate: the user adds a copy of the element after it. On a child of a repeated element, the panel also shows the arrows to move the repeated element up or down.CMS_removeenables Remove. Copies made with Duplicate getCMS_removetoo.
Give the first item CMS_repeat only, and the others CMS_repeat CMS_remove, if the widget must always keep one item.
Hold other widgets
An element with CMS_widgets is an area where the user can add other widgets with Add a widget. Columns, boxes and panels use it. The area can be empty in the file.
Content for the editor only
An element with CMS_editor (or CMS_trash) appears in the editor and is removed from the public page. Use it for hints:
<script total>
exports.id = 'note';
exports.name = 'Note';
exports.author = 'Jane Doe';
exports.version = '1';
</script>
<style>
.CLASS-hint { font-size: 12px; color: #C00; }
</style>
<body>
<div class="CLASS-hint CMS_editor">This line is visible only in the editor.</div>
<p class="CMS_edit">A short note for the visitors.</p>
</body>The editor adds the class CMS_preview to the body of the page that it shows. Use it in your styles to show in the editor what visitors see only after a click, such as the answers of Questions:
.CMS_preview .CLASS-answer { display: block; }All classes are listed in the Editor classes reference.