Hi,
Please, how do you hide replacement tokens (argument) if empty? In my case:
Under account setting, I create a new field called userpic.
Message text:
!userpic of !foo

Rules:
Set a data value to !userpic (user picture url).
Set a data value to !foo (user name).

If a user has picture, replacement tokens is ok: userpic-url of name.
But If a user doesn't have picture, replacement tokens said !userpic of name.
Is it normal?

Thanks for the awesome module!

Files: 
CommentFileSizeAuthor
#13 message.tokenclear-1907264_2.patch639 bytesmhaamann
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch message.tokenclear-1907264_2.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#10 message.tokenclear-1907264_1.patch763 bytesjbekker
PASSED: [[SimpleTest]]: [MySQL] 69 pass(es).
[ View ]
#8 message.tokenclear.patch801 byteskingandy
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in message.tokenclear_0.patch.
[ View ]
#5 message.tokenclear.patch801 byteskingandy
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in message.tokenclear.patch.
[ View ]

Comments

I have the same problem, does anyone have a solution?

It seems to work the way I want to when I hack the GetText function in message/includes/message.message.inc
And add the following code right under $token_options = message_get_property_values($this, 'data', 'token options');

$token_options[clear] = TRUE;

So my next question is, can I alter "$this, 'data', 'token options'" for specific messages?

I've found a way to do this without hacking.. I'm not a Drupal PRO, is there a better way to access the message_type-> data ??

/**
* Implements hook_default_message_type_form_alter().
*/
function hook_form_message_type_form_alter(&$form, &$form_state) {
  $form['data']['token options']['clear'] = array(
    '#title' => t('Clear empty tokens'),
    '#type' => 'checkbox',
    '#description' => t('When this option is selected, empty tokens will be removed from display'),
    '#default_value' => !empty($form_state['build_info']['args']['0']->data['token options']['clear']) ? $form_state['build_info']['args']['0']->data['token options']['clear'] : FALSE,
  );
}

Rules was experiencing behaviour like this - see #1559844: Field token is not replaced when fields are blank. Is Message doing a similar manual token replacement process somewhere?

Wait, disregard my comment, it's using token_replace ... :P

StatusFileSize
new801 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in message.tokenclear.patch.
[ View ]

Here's a patch rolled incorporating #2's form_alter code into the form builder - it's based on the version packaged with Commerce-Kickstart (7.x-1.5) so I'm not sure if it'll be valid against 7.x-1.7 ... Also, probably a parent fieldset (similar to $form['data']['purge']) would be a good idea.

Category:support» feature
Status:Active» Needs review
StatusFileSize
new801 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in message.tokenclear_0.patch.
[ View ]

Posting again with "Needs review" to lure in the testbot. (Apologies for the postspam.)

Status:Needs review» Needs work

The last submitted patch, message.tokenclear.patch, failed testing.

Version:7.x-1.7» 7.x-1.x-dev
Status:Needs work» Needs review
StatusFileSize
new763 bytes
PASSED: [[SimpleTest]]: [MySQL] 69 pass(es).
[ View ]

I couldn't apply last patch against the latest dev, this one adds the checkbox above the Purge settings fieldset.

Status:Needs review» Fixed

Committed, thanks.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Needs review
StatusFileSize
new639 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch message.tokenclear-1907264_2.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Patch in #10 does not fix all scenarios. I am sorry that i cannot explain my scenario better.

But i tracked the bug down to this line. It never loaded the token options:
$token_options = !empty($this->data['token options']) ? $this->data['token options'] : array();

The attached patch fixes tokens not being replaced in the function save() in file: message.message.inc
Its just a copy/paste from how you load the token options in getText() function in the same file - And it works!

Status:Needs review» Needs work

The last submitted patch, message.tokenclear-1907264_2.patch, failed testing.

Can you please re-roll, so simpletest can run.

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, 13: message.tokenclear-1907264_2.patch, failed testing.

Issue summary:View changes

Patch needs a re-roll