Skip to content

Instantly share code, notes, and snippets.

@froemken
Last active August 18, 2023 09:34
Show Gist options
  • Save froemken/dccbfad4db8362f39485939bf7083b10 to your computer and use it in GitHub Desktop.
Save froemken/dccbfad4db8362f39485939bf7083b10 to your computer and use it in GitHub Desktop.
Newsletter subscription and unsubscribe TypoScript for extension powermail, based on TYPO3
# PART 1 FOR SUBSCRIBE
# AT THE END OF THIS FILE YOU WILL FIND PART 2 FOR UNSUBSCRIBE,
# WHICH HAS TO BE ADDED ON A DIFFERENT PAGE
plugin.tx_powermail.settings.setup {
# Mail log persistence must be active because of double opt-in
db.enable = 1
dbEntry.1 {
# Enable dbEntry to insert new hidden subscriber (before OPT-IN)
_enable = TEXT
_enable.value = 1
_enable.if.value = create
_enable.if.equals.data = GP:tx_powermail_pi1|action
# Set tableName to "tt_address"
_table = TEXT
_table.value = tt_address
# Do nothing, if a record with given email address already exists
_ifUnique.email = none
# optional: add additional where clause (only in mode "update") for search if a record still exists.
# You could use a plain string (see example below) or a cObject if needed
_ifUniqueWhereClause = AND pid = 83
# Fill tt_address.pid
pid = TEXT
pid.value = 83
# Fill tt_address.tstamp with the current time as timestamp (like 123456789)
tstamp = TEXT
tstamp.data = date:U
# Fill tt_address.crdate with the current time as timestamp (like 123456789)
crdate = TEXT
crdate.data = date:U
# Set tt_address.hidden to 1. Record will be un-hide after optinConfirm
hidden = TEXT
hidden.value = 1
# Fill tt_address.email with the value from powermail {email}
email = TEXT
email.field = email
# Fill tt_address.module_sys_dmail_html with 1
module_sys_dmail_html = TEXT
module_sys_dmail_html.value = 1
}
dbEntry.2 {
# Enable dbEntry to un-hide hidden subscriber (after OPT-IN)
_enable = TEXT
_enable.value = 1
_enable.if.value = optinConfirm
_enable.if.equals.data = GP:tx_powermail_pi1|action
# Set tableName to "tt_address"
_table = TEXT
_table.value = tt_address
# Update tt_address record, if email matches
_ifUnique.email = update
# optional: add additional where clause (only in mode "update") for search if a record still exists.
# You could use a plain string (see example below) or a cObject if needed
_ifUniqueWhereClause = AND pid = 83
# Un-hide tt_address record
hidden = TEXT
hidden.value = 0
# Update tstamp column
tstamp = TEXT
tstamp.data = date:U
# Add email column again, as needed to identify record while processing _ifUnique property
email = TEXT
email.field = email
}
}
# PART 2 FOR UNSUBSCRIBE
# FOLLOWING PART HAS TO BE INSERTED ON ANOTHER PAGE!!!
plugin.tx_powermail.settings.setup {
# Mail log persistence can be deactivated here. We don't have any double opt-in here.
db.enable = 0
dbEntry.1 >
dbEntry.1 {
# Enable or disable db entry for table tt_address
_enable = TEXT
_enable.value = 1
# Set tableName to "tt_address"
_table = TEXT
_table.value = tt_address
# Update tt_address record, if email matches
_ifUnique.email = update
# optional: add additional where clause (only in mode "update") for search if a record still exists.
# You could use a plain string (see example below) or a cObject if needed
_ifUniqueWhereClause = AND pid = 83
# Needed to identify the tt_address record. See: _ifUnique.*
email = TEXT
email.field = email
# Fill tt_address.tstamp with the current time as timestamp (like 123456789)
tstamp = TEXT
tstamp.data = date:U
# Update tt_address.delete to 1
deleted = TEXT
deleted.value = 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment