Automatic newsletter


  1. Introduction
  2. Set up an automatic newsletter
    1. Example
      1. Automatic newsletter declaration
      2. Declaration of associated filters
        1. Filter content rights
        2. Automatic newsletter for intranets (from version 4.8)
      3. Associated information letter template

 

This page is intended for integrators with a minimum knowledge of HTML, CSS, XML, XSL, I18N.
You must have read the Graphics integration page

Introduction

An automatic newsletter is a pre-configured newsletter that is sent to subscribers at set intervals.

The newsletter is created, filled in, validated and sent to subscribed users without any intervention from a contributor.

Automatic newsletters are configured by the application integrator.

Set up an automatic newsletter

The definition of an automatic newsletter is static and defined by an extension point org.ametys.plugins.newsletter.auto.AutomaticNewsletterExtensionPoint in a plugin.xml.

This extension point defines:

  • The wording of the newsletter
  • Description of the newsletter. For the contributor's understanding, it is strongly recommended to specify the newsletter's content and frequency.
  • The title of the newsletter. This title is used in the subject line of the mail newsletter. The joker number can be used for the newsletter number.
    Exemple: "Titre de ma lettre d'information {number}"
  • The frequency of the mailing. The frequency can be either weekly ("week") or monthly ("month"). In both cases, you must specify the day or days of the mailing, separated by commas. For weekly mailings, the day number corresponds to the day of the week (e.g.: 1=Monday, 4=Thursday). For monthly mailings, the day number corresponds to the day of the month.
  • Content filters which will be uploaded and displayed in the newsletter. These are static filter identifiers (org.ametys.cms.filter.ContentFilterExtensionPoint) defined elsewhere in the application. Filters are given a name so that you know where to display the corresponding content in the newsletter template.

Example

Case of a newsletter that will be sent out every week on Mondays and Saturdays, containing the latest 5 events published on the site.

Events will be displayed in the "contents" area of the template.
An item to be highlighted will be displayed in the "zoom" area of the template.

Automatic newsletter declaration

<extension
   point="org.ametys.plugins.newsletter.auto.AutomaticNewsletterExtensionPoint"
   class="org.ametys.plugins.newsletter.auto.StaticAutomaticNewsletter"
   id="automatic.newsletter.events">
 <label i18n="false">Lettre d'information des derniers événements</label>
 <description i18n="false">Lettre d'information des 5 derniers événements envoyée chaque semaine</description>
 <newsletter-title i18n="false">Journal des événements n°{number}</newsletter-title>
 <frequency type="week">1,6</frequency>
 <filters>
   <filter name="contents" id="newsletter.events.filter" />
   <filter name="zoom" id="newsletter.zoom.filter" />
 </filters>
</extension>

Declaration of associated filters

Filter to display the last 5 events published (an event is news content tagged as an event).

<extension point="org.ametys.cms.filter.ContentFilterExtensionPoint"
   class="org.ametys.web.filter.StaticWebContentFilter" 
   id="newsletter.events.filter">
 <title i18n="false">Filtre des derniers événements</title>
 <description i18n="false">Filtre des derniers événements pour la lettre d'info automatique</description>
 <content-types>
   <type id="org.ametys.plugins.news.Content.news" />
 </content-types>
 <tags>
   <tag key="NEWS_EVENT" />
 </tags>
 <view>abstract</view>
 <context type="current-site" lang="current" />
 <max-result>5</max-result>
 <sort-information>
   <sort metadataId="lastValidationDate" ascending="false"/>
 </sort-information>
</extension>

Filter to bring up article-type content that will be highlighted in the newsletter (last published article tagged "zoom").

<extension point="org.ametys.cms.filter.ContentFilterExtensionPoint"
   class="org.ametys.web.filter.StaticWebContentFilter" 
   id="newsletter.zoom.filter">
 <title i18n="false">Zoom sur un article</title>
 <description i18n="false">Filtre pour le zoom pour la newsletter automatique</description>
 <content-types>
   <type id="org.ametys.web.default.Content.article" />
 </content-types>
 <tags>
   <tag key="CONTENT_ZOOM" />
 </tags>
 <view>abstract</view>
 <context type="current-site" lang="current" />
 <max-result>1</max-result>
 <sort-information>
   <sort metadataId="lastValidationDate" ascending="false" />
 </sort-information>
</extension>
Filter content rights

The content brought up by the filters must be public content (accessible to anonymous users).
As the automatic newsletter is built and sent by the application, the filters are executed without a current user.

Filters should therefore not be configured with <handle-user-access> à true (cf. Static filter on content)

Automatic newsletter for intranets (from version 4.8)

From version 4.8 onwards, for intranet newsletters, it is possible to configure filters with a new configuration, enabling the inclusion of content accessible to logged-in users.

To do this, filters must be configured with the following option:

<access-limitation>anyconnected-access</access-limitation>

There are 3 possible values for "access-limitation":

  • page-access default value, strictly equivalent to handle-user-access=false. In the case of the auto newsletter, only public content can be uploaded.
  • user-access strictly equivalent to handle-user-access=true. Current user rights taken into account. In the case of the auto newsletter, this configuration cannot work.
  • anyconnected-access: filter content will only be displayed if it is public or accessible to all connected users. This mode should only be used for automatic intranet newsletters.

Associated information letter template

File skins/[skinName]/newsletter/[templateName]/models/model.xml

<model lang="fr"> 
<table id="newsletter-sheet" cellpadding="0" cellspacing="0">
<tr>
<td id="newsletter-post">
<div class="edito-sheet">
<h1>Edito</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Aenean pharetra ultrices eleifend. Suspendisse non odio justo, at elementum lorem. 
Etiam eu tellus et leo varius mollis. In diam sem, placerat in molestie id, laoreet id ante. 
Sed pretium tempus purus ut euismod. Aliquam in libero nulla, ut viverra tellus.
</p>
</div>
<div class="articles" auto-newsletter-ignore-if-empty="contents">
<p auto-newsletter-insert-filter="contents" auto-newsletter-insert-level="3">Insérez vos contenus ici</p>
</div>
</td>
<td id="newsletter-sidebar1">
<div class="encart" auto-newsletter-ignore-if-empty="zoom">
<h2>Zoom</h2>
<p auto-newsletter-insert-filter="zoom" auto-newsletter-insert-level="3">Aliquam sed ante libero. Phasellus aliquet tincidunt mauris. Praesent luctus lobortis elit, eget eleifend lacus dapibus pellentesque.</p>
</div>
</td>
</tr>
</table>
</model>

Several specific attributes are used to define the behavior of the automatic newsletter:

  • auto-newsletter-ignore-if-empty="contents": this block will not be displayed in the newsletter if no content is returned by the "contents" filter.

  • auto-newsletter-insert-filter="contents": defines the HTML element which will contain all the contents returned by the "contents" filter. The content of the element in the template (tags and textual content) is replaced by the content of the filter.

  • auto-newsletter-insert-level="3": title level of content uploaded to this zone

For example, if the "contents" filter finds two contents and the "zoom" filter finds none, the automatic newsletter will have the following content:

<table id="newsletter-sheet" cellpadding="0" cellspacing="0">
<tr>
<td id="newsletter-post">
<div class="edito-sheet">
<h1>Edito</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Aenean pharetra ultrices eleifend. Suspendisse non odio justo, at elementum lorem. 
Etiam eu tellus et leo varius mollis. In diam sem, placerat in molestie id, laoreet id ante. 
Sed pretium tempus purus ut euismod. Aliquam in libero nulla, ut viverra tellus.
</p>
</div>
<div class="articles">
<p>
<div class="article">Contenu 1...</div>
<div class="article">Contenu 2...</div>
</p>
</div>
</td>
<td id="newsletter-sidebar1"></td>
</tr>
</table>

The newsletter template and its model can be used for both manual and automatic newsletters. In the case of a manual newsletter, specific attributes will be ignored.

Back to top

Newsletter