I'm trying to program a rule that only gets executed if a CCK text field has less than a certain amount of characters.

My idea was to add the condition "numeric comparison" to the rule, but i don't know how to extract the numer of characters from the CCK text field. (I'm using token, so in my case the name of the field is [node:field_text-raw].) I searched through the forum and documentation but couldn't find any help on that.

Does anybody have a suggestion/solution? Thanks.

Comments

amitaibu’s picture

Status: Active » Fixed

You can use a PHP condition and <?php return count($node->YOUR_FIELD_NAME[0]['value']) >= 1; ?>

axel_exa’s picture

Status: Fixed » Active

Thanks for the quick reply. I didn't get it running, though. I activated the PHP module, defined a rule with a condition (truth value) and inserted the code

<?php return count($node->field_text[0]['value']) >= 5; ?>

It always returns 1. I'm sure i'm missing something very obvious here.

axel_exa’s picture

Status: Active » Fixed

I have it now: the trick was to use strlen instead of count.

Status: Fixed » Closed (fixed)

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