How to display or hide a Views field based on it's length? I have 2 fields in Views the first of which is always displayed, and the second I would like to display only if the first field has more than 70 characters. I have tried to do this using Views Conditional module but for some reason it does not work.



I have also tried this using Views PHP module by using drupal_strlen and replacement patterns, but this isn't working yet either. Below is the code that I am using:

&lt;?php

if (drupal_strlen($row-&gt;comment_body) &gt;= 70) {
  print $row-&gt;php;
} else {
  print $row-&gt;nothing_1;
}
?&gt;


How can this be done?
In the views conditional field you are comparing the string value to the value 70, not the length of the string.

And the $row variable in views is very limited.

For the field that you want to do a length comparison on, if it is a PHP field already, then before you do the print statement set the following:

&lt;?php
$data-&gt;custom_len_70 = strlen($output);
?&gt;


$output is whatever you are going to print as the value of the field, so your naming is obviously different.

Then create another PHP field after that one, exclude it from display, and set its output code to:

&lt;?php print $data-&gt;custom_len_70;?&gt;


You have now created a hidden field which has the value of the length of the field you require.

Now you can use the Views Conditional field to do a comparison.