Building your own layout¶
The most common reason: your legal details should go into the footer. That is worth a template of your own, and it is done in twenty minutes.
You need access to your website's files for it — over FTP, through your host's file manager or through the WordPress file editor.
1. Pick a template¶
Newsletter → Templates. Find the one closest to your goal.
Note the file name. It is shown in the gallery under the template's name, and again in the address when you click View full size:
…&vorlage=kopfbalken.php
2. Copy the file¶
The supplied templates live under
wp-content/plugins/wpnewslettergermany/views/layouts/
Do not work in this directory
Every change there is gone with the next update.
Copy the file to one of these two places:
| Place | When |
|---|---|
<your theme>/wpng_views/layouts/ |
If the layout belongs to the theme. The right place with a child theme |
wp-content/uploads/wpng/user_views/layouts/ |
If it should be independent of the theme. Survives a theme change too |
You may have to create the directories.
Replace or add?¶
| File name | What happens |
|---|---|
The same as the supplied one, e.g. kopfbalken.php |
Your version replaces the supplied one. There is still one entry in the gallery |
A new one, e.g. hausbrief.php |
Your version is added as a further template |
Use a new name. Then you can compare at any time, and you keep receiving improvements to the supplied template.
3. Set the name¶
At the very top of the file is a header. Change the Vorlagenname: line:
<?php
/**
* Vorlagenname: Our house letter
*/
defined( 'ABSPATH' ) || exit;
?>
That is the name shown in the gallery and in the newsletter's selection list. Without the line, the file name appears there.
The ABSPATH line has to stay
Without it the file can be called directly through the browser.
Also delete the line Veraltet: ja if you started from Standard or
Example — otherwise your template appears in the gallery under „From earlier
versions".
4. Enter your legal details¶
Look for the italic sentence in the file:
Your legal details belong here: postal address, authorised representative, contact.
Replace it with your own details. What belongs there is the same as in your imprint — a newsletter is business communication.
Bergquell Manufaktur GmbH · Am Mühlgraben 4 · 99628 Buttstädt<br />
Managing director: Anke Brandt · HRB 12345 Amtsgericht Jena<br />
Telephone +49 36372 000 · post@bergquell.test
5. Look at it in the gallery¶
Newsletter → Templates. Your template is now there, with your logo, your accent colour and dummy text.
If it does not appear:
| Check | |
|---|---|
| Is it in the right directory? | See step 2 |
Does the file name end in .php? |
A .phtml works too, .html does not |
Is the option wpng_ignoreuserview set? |
It disables custom templates entirely. There is no field for it — if it is in your database, somebody set it by hand |
6. Test — in a mail, not just in the gallery¶
Create a newsletter, choose your template and send a test mail to yourself.
The gallery is rendered by your browser. The mail is rendered by Outlook. Those are not the same thing.
What you may change — and what you may not¶
Must stay¶
<?php echo $this->view['content']; ?>
The content from the editor.
<?php $this->callMods( 'html_content', array( &$this->view['abonnent'], &$this->view['nl'] ) ); ?>
The hook for the modules. The tracking pixel of the Statistics hangs on it — without it no opens are counted, and there is no error message.
And the unsubscribe link, %deregisterurl% or %deregisterlink%. It is
mandatory, not decoration.
You may change¶
Colours, spacing, font sizes, the order of the blocks, all the texts.
Four rules that came out of mistakes¶
1. No * { … }. A universal selector also hits the content from the
editor. Up to 2.0 a supplied template used it to set font-weight: normal on
everything — what the operator wrote in bold arrived normal. It did not show
in the preview because the browser uses the same stylesheet.
2. Leave the head complete. <!DOCTYPE html> on the first line,
<html lang>, <meta name="viewport"> and <meta name="color-scheme">.
Without the last one, Apple Mail darkens your mail by itself and recalculates
the colours.
3. width="600", not width="600px". A unit in the attribute is invalid
and gets discarded. The pixel value goes in additionally as a style —
Outlook reads the attribute, the others read the style.
4. Nothing from foreign servers. No stylesheet, no font from Google. A mail program will not load it, and where it would, it would be a data protection problem.
Placeholders in the template¶
Write them as %name% directly into it. The ones mostly needed in a shell:
%deregisterurl% |
The recipient's personal unsubscribe address |
%deregisterlink% |
The same link, ready-made |
%nl_onlinelink% |
„View newsletter in your browser" |
%nl_name% |
The name of the issue |
%privacylink% |
Your privacy policy |
The full list is under Placeholders.
What happens with the next update¶
Nothing to your file. It sits outside the plugin folder.
If a supplied template comes in an improved version, you will not get it as long as one of your own with the same name sits on top. That is exactly why step 2 advises a new name.
All the same, do look after a major update to see whether something has changed in the supplied version that you want to adopt.
And if you would rather not¶
For the legal details there is a way without a file of your own: write them at the bottom of the editor, in every issue.
More cumbersome, but no FTP needed. The Copy button in the newsletter list takes them along into the next issue.