Is it possible to define message templates in code/files somehow?

If not, this is actually a feature request. Would be a perfect fit for Ctools' exportables API, wouldn't it?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dane Powell’s picture

Title: Defining message templates in files » Make message templates exportable
Category: support » feature

Agreed, it would be really helpful if message templates could be exported and overridden (via Features). Shouldn't be too hard to code I imagine, but the ROI isn't high enough for me to tackle it myself :)

Also, this might only officially happen in 4.x, which is fine- but I'd appreciate a patch for 2.x as well, since not all of us are able to upgrade (being bound to Open Atrium and the like...)

Dane Powell’s picture

Status: Active » Closed (won't fix)

I don't think any new features are going in 2.x

maddentim’s picture

Version: 6.x-2.x-dev » 6.x-4.x-dev
Status: Closed (won't fix) » Active

Making templates exportable would be useful. Certainly from a convenience standpoint, but also from a security / stability standpoint. Since these templates drive emails to my clients, I was fear somehow one of these variables reverting the default instead of the customized message.

Can this be considered for 6.x-4.x? or in 7.x? Or is it already supported?

EugenMayer’s picture

not in 4.x yet. Iam considering helping out here, if the maintainer interested

Dane Powell’s picture

I am not a true "maintainer" but I do have commit access. If you can get a patch to RTBC I will commit it.

EugenMayer’s picture

Well my plan:
- integrate it with ctools exportables
- integrate it that way using features

the module will probably get to big, might be better to start it as a own project to split maintanace? What do you think?

Dane Powell’s picture

Yeah, you might consider adding it to the "notifications_extra" package. It just depends on exactly how big it gets.

EugenMayer’s picture

well, what about http://drupal.org/node/800614 ? is that one compatible with 4.x?

EugenMayer’s picture

Its looks pretty good, eventhough its not integrated using ctools exportables.

AFAIC the only issue is the submit form, as tpid is not build in, which will create dupes and will not work out ( tpid has been invented in 4.x ). So more or less, the integration is not bad, but will not work out for 4.x OOTB. In addition, language is also missing, so that one will need to get fixed also

- AFAIC we need a identifier-touple of (type, msgkey, method, module, language) . Iam not very sure about module though.
- Data fields are: format, data, message
- skippoing tpid, as it seems to be only used for "updates" in the admin form.

So basically i would integrate the identifier touple with ctools-exportables, in addition i would use the http://drupal.org/project/exportables contrib to build up the mapping table. Thats it. Some feature hooks to define what is exportable and should be it

malcomio’s picture

FileSize
3.64 KB

Here's a patch based on the version 2 patch from http://drupal.org/node/800614

I haven't had time to look into exportables, but it seems to work.

malcomio’s picture

Status: Active » Needs review
FileSize
3.77 KB

realised I'd left out module and language - try again...

fatfish’s picture

FileSize
3.92 KB

Fix language store. I added language code as additional variable (e.g. ::en) to the feature key. Now we can select to export/revert messaging template at any language individual.
The key principly is key structure as created here:

foreach ($defaults as $key => $message) {
    list($type, $msgkey, $method, $language) = explode('::', $key);
    $settings[$type][$msgkey][$method][$language] = $message;
}