While working on #183120: Support Token module i've came to some thoughts about personalisation and further evolution of simplemail.

One primary component of personalisation is Token support.
A second important component is conditional output - or output logic - which is not really possible with tokens.

I've thought about adding it using input filters (there are many token-like input filters that implement kinda token with arguments) and then realized the aim is currently impossible to reach.

Currently we're caching node content after node_build_content and drupal_render per nid. And since the filter is getting applied, all mails will have the same content. In general logic is also not possible before token replacement, but needs to get applied after (e.g. to check if a user has entered his real name or not).

For the moment the potential issue is: If input filters provide dynamic/uncachable information, we're doing things wrong. But there's currently no real information to decide - as far as i know.

So... no drupal filters... but some specific filter-like system seems to be needed. With context.

Any thoughts welcome!

Comments

miro_dietiker’s picture

Title: Personalisation in simplemail » Conditional personalisation and dynamic (uncacheable) filters
sutharsan’s picture

Conditional replacement is very specific for emails or other outgoing messages. It is by nature different from rendering node content which is always the same for all visitors. Therefore we should not look a node based solutions but can get our inspiration from it. What about a filter hook which acts only on outgoing emails. It should also provide a method for testing the behaviour, e.g. preview, re-route to test-address.

kwinters’s picture

The Mail Chimp dynamic content feature is very good, if you want something to emulate.

sutharsan’s picture

Status: Active » Closed (won't fix)

Simplenews module is not the place to build a conditional token function into. I suggest you build a separate module for this since it can be usefull in many situations outside of Simplenews.