Skip to main content
With the $wsNewsletter module, you can access newsletter functions. Typical use cases are subscription forms with target group selection, newsletter management in the customer account, or unsubscribe links in emails. In this section, you will learn how to load target groups and create newsletter forms.

Module overview

Example / excerpt of $wsNewsletter
{{= $wsNewsletter | json }}
JSON output
{
  "getTargetGroups": "ƒ()"
}
Note: ƒ() denotes a function. Methods overview
MethodReturn typeDescription
getTargetGroups()arrayLoads the available newsletter target groups.

Templates

Newsletter forms are typically used in the following places:
  • Footer: compact subscription form with email field.
  • Custom page: detailed form with target group selection and additional fields.
  • Customer account: management of newsletter subscriptions.

Variables

No variables are available for $wsNewsletter.

Methods

$wsNewsletter.getTargetGroups()

Loads the available newsletter target groups. Signature
$wsNewsletter.getTargetGroups()
Return value
array - List of available target groups.
Example that loads all target groups.
{{ var $myTargetGroups = $wsNewsletter.getTargetGroups() }}
{{ foreach $targetGroup in $myTargetGroups }}
    {{= $targetGroup.name }} - {{= $targetGroup.id }}
{{ /foreach }}

Actions

No actions are available for $wsNewsletter.

Examples

Subscription form with target group selection

{{ var $targetGroups = $wsNewsletter.getTargetGroups() }}

{{ if $targetGroups }}
  <p>Select newsletter:</p>
  {{ foreach $group in $targetGroups }}
    <label>
      <input type="checkbox" name="targetGroupId" value="{{= $group.id }}">
      {{= $group.name }}
    </label>
  {{ /foreach }}
{{ /if }}