====== Content Areas ====== ---- plugin ---- description: Use any number of content areas within a campaign's message that can be edited individually. author : Duncan Cameron type : lastupdate : 2015-10-02 compatible : phplist 3 depends : conflicts : similar : tags : sourcerepo : https://github.com/bramley/phplist-plugin-contentareas donationurl: ---- ====== Purpose ====== This plugin allows you to use any number of content areas in a campaign message, each of which can be edited individually. The approach is to add extra information, as attributes, to the template that indicate which HTML elements can be edited. The plugin then displays the template showing the editable areas, and the contents of each area can be edited. This approach helps you to separate the content of your newsletter from the html structure. How you actually use a content area is flexible. It can be as simple as the plain text for a
Default article title
The default article content
===== Advanced attributes =====
Using the data-edit attribute you can identify each of a fixed number of elements as being editable.
If you need a more flexible number of articles then you can use the repeatable attribute or the hideable attribute.
==== data-repeatable attribute ====
This attribute is used to identify a chunk of HTML that includes editable content that can be used many times. When composing a message you can add further instances of the repeated chunk, and also remove instances. The content may contain data-edit attributes, but not data-repeatable nor data-hideable attributes.
The value of the attribute is a name that should be unique within the template.
The plugin will simply repeat the element with the attribute and all its child elements, so the attribute should be added only to elements that validly can be repeated in this way. If your template is table-based then it should be added to a ''tr'' element to repeat a row of a table, or added to a ''table'' element to repeat the whole table.
If the layout is div based then the attribute can be added to a ''div'' element.
This approach allows you to dynamically add further content such as articles without having to define each article individually in the template.
Here is an example that will allow a table row that includes an article title and article content to be repeated.
Default article title
The default article content
A repeatable area need not have any instances, in which case it will not be included in the final email HTML. Initially a repeatable area is displayed disabled. You need to add an instance to be able to edit its content.
==== data-hideable attribute ====
The hideable attribute is used to remove a section from the final email. This allows you to have optional sections and to remove them when they are not needed in a particular campaign. The content may contain data-edit attributes, but not data-repeatable nor data-hideable attributes.
Here is an example of defining a hideable area which has one content field
Initially, a hideable area is not hidden, and its content fields can be edited. If the area is then made hidden it is grayed-out when editing, but will be removed when the final email is built.
===== Table of contents =====
You can use the ''data-toc'' attribute to automatically create a table of contents from all occurrences of a specific element. That element should be used as the title or subtitle of each article in the newsletter.
The attribute should be added to an element that provides the heading for the table of contents. The plugin will then add links to each of the selected elements immediately after the title. In this example all
In this newsletter
I am Ishmael
The plugin will then generate a table of contents comprising links to each ''
The toc is then styled using this css
.toc div {
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: bold;
text-align: left;
margin-top: 0px;
margin-bottom: 6px;
color: #2222CC;
}
.toc p {
list-style:circle inside;
display:list-item;
padding-left: 20px;
}
.toc a {
text-decoration:none;
color: #333333;
}
and is then displayed
[CONTENT]
Add a data-edit attribute to the container element and comment-out the CONTENT placeholder.
===== Creating a campaign =====
To use the template for a message, create a new message in the usual way then on the Format tab select the template. After moving onto the next tab, the plugin will have created a new tab with the title "Edit Areas". This will usually be tab 2 but may be later depending on whether you have other plugins installed.
The tab displays the template with each editable content field annotated with an edit button.
and to enter some nominal text on the Content tab, such as 'content' or even a single character. In effect the placeholder will then be ignored.
===== Inline CSS styles =====
Previous versions of the plugin provided an option to inline CSS in the body of the emails sent by phplist. This feature is now provided by Common Plugin, see https://resources.phplist.com/plugin/common
===== View email in browser =====
The plugin can be used with the [[plugin:viewbrowser|View in Browser plugin]] to provide a link that displays the campaign in a browser. Prior to version 2.4.0 of the plugin this plugin's own placeholders had to be used: [CAVIEWBROWSER] and [CAVIEWBROWSERURL].
Those are now longer needed nor supported. You should use the placeholders provided by the View in Browser plugin
[VIEWBROWSER] and [VIEWBROWSERURL].
To avoid any problem with incompatible plugin versions you should upgrade to the latest version of this plugin and of the View in Browser plugin.
====== Configuration ======
The plugin adds a Content Areas group to the Settings page where you can enter:
* The package to use to inline CSS styles - PreMailer or Emogrifier. If you have problems with either package then you can disable inlining by choosing None.
* The plugin displays the template and content in an iframe, both when editing content areas and when viewing a message. You can configure the height and width of the iframe.
{{:plugin:content_12.png?nolink&300|}}
====== Change Log ======
See the GitHub page https://github.com/bramley/phplist-plugin-contentareas#version-history