Email Templates¶
Overview¶
Email templates in the Gold Standard Module handle all notification emails sent to users, including new article alerts, comment notifications, and moderation updates. These templates integrate with XOOPS's notification system while supporting modern HTML email design.
Email Template Architecture¶
flowchart TB
subgraph "Email Generation"
A[Event Triggered] --> B[Notification Handler]
B --> C[Load Template]
C --> D[Variable Substitution]
D --> E[Generate HTML/Text]
E --> F[Send Email]
end
subgraph "Template Types"
G[Notification Emails]
H[Digest Emails]
I[Admin Alerts]
end Template Location¶
Email templates are stored in:
modules/goldstandard/language/{language}/mail/
├── notify_new_article.tpl
├── notify_new_comment.tpl
├── notify_article_approved.tpl
├── notify_comment_reply.tpl
├── digest_weekly.tpl
└── admin_pending_review.tpl
Template Variables¶
Global Variables¶
Available in all email templates:
| Variable | Description |
|---|---|
{X_SITENAME} | Website name |
{X_SITEURL} | Website base URL |
{X_ADMINMAIL} | Admin email address |
{X_MODULE} | Module name |
{X_UNAME} | Recipient username |
{X_UID} | Recipient user ID |
{X_UNSUBSCRIBE_URL} | Unsubscribe link |
Article-Related Variables¶
| Variable | Description |
|---|---|
{ARTICLE_TITLE} | Article title |
{ARTICLE_URL} | Full article URL |
{ARTICLE_EXCERPT} | Article excerpt |
{ARTICLE_AUTHOR} | Author name |
{ARTICLE_CATEGORY} | Category name |
{ARTICLE_DATE} | Publication date |
Comment-Related Variables¶
| Variable | Description |
|---|---|
{COMMENT_AUTHOR} | Comment author name |
{COMMENT_TEXT} | Comment content |
{COMMENT_DATE} | Comment date |
{COMMENT_URL} | Direct link to comment |
Email Templates¶
New Article Notification (notify_new_article.tpl)¶
Hello {X_UNAME},
A new article has been published in {ARTICLE_CATEGORY}:
**{ARTICLE_TITLE}**
{ARTICLE_EXCERPT}
Read the full article:
{ARTICLE_URL}
---
You are receiving this email because you subscribed to new article notifications on {X_SITENAME}.
To unsubscribe from these notifications, visit:
{X_UNSUBSCRIBE_URL}
---
{X_SITENAME}
{X_SITEURL}
New Article Notification - HTML Version¶
<!-- notify_new_article_html.tpl -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Article: {ARTICLE_TITLE}</title>
<!--[if mso]>
<style type="text/css">
table { border-collapse: collapse; }
.content { width: 600px; }
</style>
<![endif]-->
</head>
<body style="margin: 0; padding: 0; background-color: #f4f4f4; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;">
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="center" style="padding: 20px 0;">
<!-- Email Container -->
<table class="content" role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<!-- Header -->
<tr>
<td style="background-color: #2563eb; padding: 30px; text-align: center;">
<h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: 600;">
{X_SITENAME}
</h1>
</td>
</tr>
<!-- Content -->
<tr>
<td style="padding: 40px 30px;">
<p style="margin: 0 0 20px; color: #6b7280; font-size: 14px;">
Hello {X_UNAME},
</p>
<p style="margin: 0 0 20px; color: #374151; font-size: 16px;">
A new article has been published in <strong>{ARTICLE_CATEGORY}</strong>:
</p>
<!-- Article Card -->
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin: 20px 0; background-color: #f9fafb; border-radius: 8px;">
<tr>
<td style="padding: 20px;">
<h2 style="margin: 0 0 10px; color: #111827; font-size: 20px;">
{ARTICLE_TITLE}
</h2>
<p style="margin: 0 0 15px; color: #6b7280; font-size: 14px;">
By {ARTICLE_AUTHOR} • {ARTICLE_DATE}
</p>
<p style="margin: 0 0 20px; color: #374151; font-size: 14px; line-height: 1.6;">
{ARTICLE_EXCERPT}
</p>
<a href="{ARTICLE_URL}"
style="display: inline-block; padding: 12px 24px; background-color: #2563eb; color: #ffffff; text-decoration: none; border-radius: 6px; font-weight: 500; font-size: 14px;">
Read Full Article
</a>
</td>
</tr>
</table>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="background-color: #f9fafb; padding: 20px 30px; border-top: 1px solid #e5e7eb;">
<p style="margin: 0 0 10px; color: #6b7280; font-size: 12px; text-align: center;">
You're receiving this because you subscribed to article notifications.
</p>
<p style="margin: 0; text-align: center;">
<a href="{X_UNSUBSCRIBE_URL}" style="color: #6b7280; font-size: 12px; text-decoration: underline;">
Unsubscribe
</a>
|
<a href="{X_SITEURL}" style="color: #6b7280; font-size: 12px; text-decoration: underline;">
Visit Website
</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
New Comment Notification (notify_new_comment.tpl)¶
Hello {X_UNAME},
{COMMENT_AUTHOR} has posted a new comment on "{ARTICLE_TITLE}":
---
{COMMENT_TEXT}
---
View the comment:
{COMMENT_URL}
Reply to this comment:
{ARTICLE_URL}#comments
---
You are receiving this email because you subscribed to comment notifications for this article.
To unsubscribe:
{X_UNSUBSCRIBE_URL}
---
{X_SITENAME}
{X_SITEURL}
Article Approved Notification (notify_article_approved.tpl)¶
Hello {X_UNAME},
Great news! Your article has been approved and is now published:
**{ARTICLE_TITLE}**
Your article is now live and can be viewed at:
{ARTICLE_URL}
Thank you for your contribution to {X_SITENAME}!
---
If you have any questions about the review process, please contact us at {X_ADMINMAIL}.
---
{X_SITENAME}
{X_SITEURL}
Comment Reply Notification (notify_comment_reply.tpl)¶
Hello {X_UNAME},
{REPLY_AUTHOR} has replied to your comment on "{ARTICLE_TITLE}":
Your original comment:
> {ORIGINAL_COMMENT}
Their reply:
---
{REPLY_TEXT}
---
View the conversation:
{COMMENT_URL}
---
To stop receiving reply notifications:
{X_UNSUBSCRIBE_URL}
---
{X_SITENAME}
{X_SITEURL}
Weekly Digest (digest_weekly.tpl)¶
Hello {X_UNAME},
Here's your weekly digest from {X_SITENAME}:
## This Week's Highlights
{foreach $articles as $article}
### {$article.title}
{$article.excerpt}
Read more: {$article.url}
{/foreach}
---
## Popular This Week
{foreach $popular as $article}
- {$article.title} ({$article.views} views)
{$article.url}
{/foreach}
---
## Stats
- New articles this week: {$stats.new_articles}
- Total comments: {$stats.new_comments}
- Most active category: {$stats.top_category}
---
Manage your digest preferences:
{PREFERENCES_URL}
Unsubscribe from digest:
{X_UNSUBSCRIBE_URL}
---
{X_SITENAME}
{X_SITEURL}
Admin Pending Review Alert (admin_pending_review.tpl)¶
Hello Admin,
There are articles pending review on {X_SITENAME}:
{foreach $pending as $article}
---
Title: {$article.title}
Author: {$article.author}
Submitted: {$article.submitted_at}
Category: {$article.category}
Review: {$article.admin_url}
{/foreach}
---
Total pending: {$pending_count}
Review all pending articles:
{ADMIN_PENDING_URL}
---
This is an automated message from {X_SITENAME}
Notification Configuration¶
Setting Up Notifications¶
In xoops_version.php:
$modversion['notification'] = [
'lookup_file' => 'include/notification.inc.php',
'lookup_func' => 'goldstandard_notify_iteminfo',
'category' => [
[
'name' => 'global',
'title' => _MI_GOLDSTANDARD_GLOBAL_NOTIFY,
'description' => _MI_GOLDSTANDARD_GLOBAL_NOTIFY_DESC,
'subscribe_from' => ['index.php', 'article.php', 'category.php']
],
[
'name' => 'category',
'title' => _MI_GOLDSTANDARD_CATEGORY_NOTIFY,
'description' => _MI_GOLDSTANDARD_CATEGORY_NOTIFY_DESC,
'subscribe_from' => ['category.php'],
'item_name' => 'category_id',
'allow_bookmark' => true
],
[
'name' => 'article',
'title' => _MI_GOLDSTANDARD_ARTICLE_NOTIFY,
'description' => _MI_GOLDSTANDARD_ARTICLE_NOTIFY_DESC,
'subscribe_from' => ['article.php'],
'item_name' => 'article_id',
'allow_bookmark' => true
]
],
'event' => [
[
'name' => 'new_article',
'category' => 'global',
'title' => _MI_GOLDSTANDARD_NOTIFY_NEW_ARTICLE,
'caption' => _MI_GOLDSTANDARD_NOTIFY_NEW_ARTICLE_CAP,
'mail_template' => 'notify_new_article',
'mail_subject' => _MI_GOLDSTANDARD_NOTIFY_NEW_ARTICLE_SBJ
],
[
'name' => 'new_category_article',
'category' => 'category',
'title' => _MI_GOLDSTANDARD_NOTIFY_NEW_CAT_ARTICLE,
'caption' => _MI_GOLDSTANDARD_NOTIFY_NEW_CAT_ARTICLE_CAP,
'mail_template' => 'notify_new_article',
'mail_subject' => _MI_GOLDSTANDARD_NOTIFY_NEW_CAT_ARTICLE_SBJ
],
[
'name' => 'new_comment',
'category' => 'article',
'title' => _MI_GOLDSTANDARD_NOTIFY_NEW_COMMENT,
'caption' => _MI_GOLDSTANDARD_NOTIFY_NEW_COMMENT_CAP,
'mail_template' => 'notify_new_comment',
'mail_subject' => _MI_GOLDSTANDARD_NOTIFY_NEW_COMMENT_SBJ
]
]
];
Triggering Notifications¶
namespace Xoops\Modules\GoldStandard\Infrastructure\Notification;
class NotificationService
{
public function notifyNewArticle(Article $article): void
{
$notificationHandler = xoops_getHandler('notification');
// Global subscribers
$notificationHandler->triggerEvent(
'goldstandard',
'global',
0,
'new_article',
[
'ARTICLE_TITLE' => $article->getTitle(),
'ARTICLE_URL' => $article->getUrl(),
'ARTICLE_EXCERPT' => $article->getExcerpt(),
'ARTICLE_AUTHOR' => $article->getAuthorName(),
'ARTICLE_CATEGORY' => $article->getPrimaryCategory()->getName(),
'ARTICLE_DATE' => $article->getPublishedAt()->format('F j, Y')
]
);
// Category subscribers
foreach ($article->getCategories() as $category) {
$notificationHandler->triggerEvent(
'goldstandard',
'category',
$category->getId(),
'new_category_article',
[
'ARTICLE_TITLE' => $article->getTitle(),
'ARTICLE_URL' => $article->getUrl(),
'ARTICLE_EXCERPT' => $article->getExcerpt(),
'ARTICLE_AUTHOR' => $article->getAuthorName(),
'ARTICLE_CATEGORY' => $category->getName(),
'ARTICLE_DATE' => $article->getPublishedAt()->format('F j, Y')
]
);
}
}
public function notifyNewComment(Comment $comment, Article $article): void
{
$notificationHandler = xoops_getHandler('notification');
$notificationHandler->triggerEvent(
'goldstandard',
'article',
$article->getId(),
'new_comment',
[
'ARTICLE_TITLE' => $article->getTitle(),
'ARTICLE_URL' => $article->getUrl(),
'COMMENT_AUTHOR' => $comment->getAuthorName(),
'COMMENT_TEXT' => $comment->getContent(),
'COMMENT_DATE' => $comment->getCreatedAt()->format('F j, Y'),
'COMMENT_URL' => $article->getUrl() . '#comment-' . $comment->getId()
]
);
}
}
Email Best Practices¶
Responsive Design¶
<!-- Mobile-friendly wrapper -->
<style>
@media only screen and (max-width: 600px) {
.content {
width: 100% !important;
}
.mobile-padding {
padding: 20px 15px !important;
}
.mobile-full-width {
width: 100% !important;
display: block !important;
}
}
</style>
Accessibility¶
- Use semantic HTML where supported
- Include alt text for images
- Ensure sufficient color contrast
- Provide plain text alternatives
Deliverability¶
- Keep subject lines under 50 characters
- Avoid spam trigger words
- Include clear unsubscribe links
- Use consistent "From" addresses