Ignore:
Timestamp:
10/15/09 19:30:49 (3 years ago)
Author:
KennethLavrsen
Message:

Item2260: MailerContrib cannot find email templates based on skin or web
Fixed the code so it is the topic context of WebNotify that is used when we send emails instead of the default Main.WebHome
Major update of the documentation to describe how you can tailor the email format based on web

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MailerContrib/data/System/MailerContrib.txt

    r4809 r5270  
    138138   * Set SHORTDESCRIPTION = %$SHORTDESCRIPTION% 
    139139--> 
    140 ---++ Developer Notes 
     140---+++ Tailoring the email format 
    141141The changes mails sent to subscribers are based on a Foswiki template called =mailnotify=. This template must contain the following definitions.  
    142142| =HTML:before= | Section of a HTML mail before the changes | 
     
    147147| =PLAIN:after= | Section of a plain text mail after the changes | 
    148148| =MailNotifyBody= | All the above are embedded in this. %<nop>HTML_TEXT% expands to the HTML obtained by expanding the =HTML:*= templates, and %<nop>PLAIN_TEXT% from the =PLAIN:*= templates. | 
    149 The default template sends multipart mails containing both HTML and plaintext versions. You can easily provide a custom version of this template using a local skin. 
     149The default template sends multipart mails containing both HTML and plaintext versions. 
     150 
     151To tailor the email format please avoid editing the distributed mailnotify.tmpl file as you will regret when it later gets overwritten when you upgrade Foswiki. Instead you should either use a skin setting to choose the template file or use web part of the [[%SYSTEMWEB%.SkinTemplates#FindingTemplates][template search path rules]].  
     152    
     153It is recommended to use the skin method as it is easier to control, and requires less hacking around. Especially if you need to use the same tailoring for many or all webs. 
     154 
     155   * Simple global tailoring used in all webs using your normal default skin 
     156      * Make a copy of =templates/mailnotify.tmpl= called =templates/mailnotify.skiname.tmpl=. For example =templates/mailnotify.pattern.tmpl= and modify this copy to your need. If you use the !NatSkin simply use =templates/mailnotify.nat.tmpl= instead 
     157 
     158   * Using a dummy skin name globally 
     159      * In !%USERSWEB%.SitePreferences define a setting =* Set SKIN = notifyskin,pattern= where the notifyskin is the dummy skin name and the pattern in this example is the real skin. 
     160      * Create a =templates/mailnotify.notifyskin.tmpl= with your tailorings 
     161    
     162   * Using a dummy skin name per web 
     163      * In each web where you want a special mailnotify template add the setting =* Set SKIN = notifywebname,pattern= where the notifywebname is the dummy skin name for this web and the pattern in this example is the real skin. 
     164      * For each web where you need a special mailnotify template create a =templates/mailnotify.notifywebname.tmpl= with your tailorings 
     165    
     166   * Using the web path in the templates directory 
     167      * For each web where you want a special mailnotify create subdirectories in =templates= with the same names as the webs and place a =templates/mailnotify.tmpl= in these subdirectories with your tailorings 
    150168 
    151169Newsletters are sent after formatting using the standard =view= template, using whatever skin is selected in the topic being mailed. 
     170 
     171---+++ Using a topic defined email template 
     172 
     173If you want to use a topic to define the notify email format this is possible with a small workaround. Before you go ahead and do this you need to consider the security implication. Making the email format available to any user from a browser means that spammers can abuse this to create messages where they can spoof the from address. Only use this method if your Foswiki installation is safely behind a firewall and your users can be trusted. 
     174 
     175The method can best be shown with an example. In the following we... 
     176 
     177   * Define a custom mailnotify template based on a skin setting in !WebNotify 
     178   * Allow the users to define the mail format in a topic called !WebNotifyCustomTemplate 
     179 
     180Here are the steps 
     181 
     182First we create a file =templates/mailnotify.customnotify.tmpl= which only contains these two lines 
     183 
     184<verbatim> 
     185%TMPL:INCLUDE{"mailnotify"}% 
     186%TMPL:INCLUDE{"WebNotifyCustom"}% 
     187</verbatim> 
     188 
     189In the webs where you want the topic defined mail format we add the setting =* Set SKIN = customnotify,pattern= (assuming pattern is the normal skin) 
     190 
     191And we create a topic in the web called !WebNotifyCustomTemplate which contains the entire mailnotify template you want to use. Simply copy the content from =templates/mailnotify.tmpl= to this template and do the tailoring. 
    152192 
    153193---+++ Contrib Info 
     
    160200 
    161201|  Author: | [[http://c-dot.co.uk][Crawford Currie]] | 
    162 |  Copyright &copy;: | 2004, Wind River Systems; 2008, http://WikiRing.com | 
     202|  Copyright &copy;: | 2004, Wind River Systems; 2008, http://WikiRing.com; 2009 Foswiki Contributors | 
    163203|  License: | GPL | 
    164204|  Version: | %$VERSION% | 
    165205|  Release: | %$RELEASE% | 
    166206|  Change History: | | 
    167 |  24 May 2009 | Foswikitask:Item1603: use quotes to protect topic names with odd characters in them | 
     207|  15 Oct 2009 | Foswikitask:Item2260. Make the feature that allows defining the email template based in either skin or web path. And improve the documentation so people can learn how to tailor the emails that the WebNotify feature sends. <br /> Foswikitask:Item1603: use quotes to protect topic names with odd characters in them | 
     208|  20 Sep 2009 | Small documentation update for Foswiki 1.0.7 release (RELEASE and adding parent) | 
    168209|  23 Apr 2009 | Foswikitask:Item1501: Minor bug in logfile output fixed | 
    169210|  03 Dec 2008 | Re-released for the Foswiki project | 
Note: See TracChangeset for help on using the changeset viewer.