diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index b522e0c72..2d1d0235f 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -46,6 +46,7 @@ module: metatag_open_graph: 0 metatag_twitter_cards: 0 node: 0 + opd_daily_emails: 0 options: 0 page_cache: 0 path: 0 diff --git a/config/sync/views.view.daily_email_archive.yml b/config/sync/views.view.daily_email_archive.yml index 971088544..573a23beb 100644 --- a/config/sync/views.view.daily_email_archive.yml +++ b/config/sync/views.view.daily_email_archive.yml @@ -277,7 +277,7 @@ display: plugin_id: text empty: false content: - value: '

This is an archive of the 820+ email messages I have sent to my daily mailing list since the 12th of August, 2022. Enjoy!

' + value: '

This is an archive of the [opd-daily-emails:email-count] email messages I have sent to my daily mailing list since the 12th of August, 2022. Enjoy!

' format: basic_html tokenize: false footer: { } diff --git a/modules/opd_daily_emails/opd_daily_emails.info.yml b/modules/opd_daily_emails/opd_daily_emails.info.yml new file mode 100644 index 000000000..d1e91d605 --- /dev/null +++ b/modules/opd_daily_emails/opd_daily_emails.info.yml @@ -0,0 +1,4 @@ +name: Daily Emails +type: module +core_version_requirement: ^11 +package: oliverdavies.uk diff --git a/modules/opd_daily_emails/opd_daily_emails.module b/modules/opd_daily_emails/opd_daily_emails.module new file mode 100644 index 000000000..dc117fb12 --- /dev/null +++ b/modules/opd_daily_emails/opd_daily_emails.module @@ -0,0 +1,51 @@ + t('Tokens related to daily emails.'), + 'name' => t('Daily emails'), + ]; + + $tokens['email-count'] = [ + 'description' => t('The number of sent daily emails.'), + 'name' => t('Daily email count'), + ]; + + return [ + 'tokens' => [ + 'opd-daily-emails' => $tokens, + ], + 'types' => [ + 'opd-daily-emails' => $type, + ], + ]; +} + +/** + * Implements hook_tokens(). + */ +function opd_daily_emails_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleableMetadata) : array { + $replacements = []; + + if ($type === 'opd-daily-emails') { + foreach ($tokens as $name => $original) { + switch ($name) { + case 'email-count': + $replacements[$original] = 822; + break; + } + } + } + + return $replacements; +} +