I needed token support for this module.
Simple patch:
wysiwyg_template.module: line: 244

      'body' => module_exists('token') ? token_replace($dbTemplate->body) : $dbTemplate->body,

To show available tokens when editing template:

wysiwyg_template.admin.inc: line: 86

 if (module_exists('token')) {
    $form['token_help'] = array(
      '#value' => theme('token_tree', array('global' => NULL)),
    );
  }

Hopefully this can be added to the module?

CommentFileSizeAuthor
#7 wysiwyg_template_token.patch959 bytestlaurent
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guybedford’s picture

Thanks for the suggestion, and sharing your code.

Can I just ask - what was your use case for the token module here?

sauce71’s picture

This is for an Ubercart site. I use wysiwyg in the order comments, and templates to insert text notifying the customer that they order is shipped etc. They like to use a variation of messages, and I use tokens to insert the name of the user handling / shipping the order.

guybedford’s picture

Status: Active » Closed (fixed)

Thanks - it's great to hear how the module is being used for thinking about future features!

I've committed the update for the next release.

sauce71’s picture

Thanks :)
Next challenge will be to add some more context for Tokens. The order customers name comes to mind.
Not an easy generic solution for this, will probably add some custom tokens sniffing current order from a session variable.

tlaurent’s picture

This is indeed a very useful functionality, thanks for that.
One remark I have is that if I modify wysiwyg_template.module: line: 244 as recommended by sauce71, the tokens are not translated.
On the other hand, if I modify wysiwyg_template.module: line: 212 (wysiwyg_template_html_load function) instead, then it works:
return module_exists('token') ? token_replace($template['body']) : $template['body'];

I wonder why that is ?
I'm using wysiwyg_template 6.x-2.1-beta1 with token 6.x-1.15.

guybedford’s picture

Status: Closed (fixed) » Patch (to be ported)

You're right about the above correction - tokens should be replaced when loading the template from the database, not at the point of saving. (Just like input formats are applied in Drupal).

tlaurent’s picture

Version: 6.x-2.1-beta1 » 6.x-2.2-beta1
FileSize
959 bytes

I generated a 2 lines patch for 6.x-2.2-beta1 users who would like to get the changes I mentioned above (tokens being replaced when loading the template from the database and not at the point of saving).

guybedford’s picture

Status: Patch (to be ported) » Closed (fixed)

This has now been added in the 6.x-2.3 release.