How to conditionally display some things in the message text created by the Message module? I am using the Message module to record some activity.

I have a Rule generating a Message. The Message Type has a couple of fields, and I am setting them in the rule. That part all works great. I can verify the contents of each of those message fields.

Now what I'm trying to do is to conditionally display some things in the message text. I have a couple of Message Text rows and they all display what I expect them to. But for one of these, I want only want to display something if one of the tokens matches a condition. 

I have selected the PHP Code filter type on that particular Message Text box, but I just don't know to actually evaluate the field values of the current message. I've tried t() and token_replace() and I just am not getting it.

So here is a simple question for this problem I'm having. Say I have a text field on this message type called field_foo. And I want the message text to display the length of that field. I basically want something to the effect of &lt;?php strlen(this-message:field_foo) ?&gt;.

How do I reference my message instance's field?
I couldn't figure out how to do this what I thought was the "right" way - that being inside the message type itself. 

Instead, I added a preprocess field from DisplaySuite and put that into my display. 

function mytheme_preprocess_message(&amp;$variables) {
    $message = $variables['elements']['#entity'];
    if (isset($message) &amp;&amp; $message-&gt;type == 'my_custom_message' &amp;&amp; isset($message-&gt;field_foo) &amp;&amp; array_key_exists(LANGUAGE_NONE, $message-&gt;field_attachment_themed)) {
        $html = $message-&gt;field_fooLANGUAGE_NONE][0]['value'];
        $variables['parsed_output'] = $html;
    }
}


Then I just named my preprocess field parsed_output, and it now displays exactly how I want, and I can add whatever custom code I want to my preprocess_message().