Answers.Body: <p>Looks like the CiviCRM is adding a space '<code>&amp;nbsp;</code>' (may be because of CKEditor) into the custom table column , even though you leave it empty when adding/editing the record. </p>
  
  <p>You can see it if you do var_dump of the variable. See below screenshot</p>
  
  <p><img src="https://i.sstatic.net/ZcNoJ.jpg" alt="enter image description here"></p>
  
  <p>So the below logic should work in this case. </p>
  
  <pre><code>&lt;?php
  if ($row-&gt;id_info_for_display_33 !== '&amp;nbsp;'  &amp;&amp; !empty($row-&gt;id_info_for_display_33)) {
      print $row-&gt;display_name . ", " . $row-&gt;id_info_for_display_33;
  }
  else {
      print $row-&gt;display_name;
  }
  ?&gt;
  </code></pre>
  
  <p>Give it a try.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-30T03:13:34.650Z
Answers.Text: Thanks... This def helped me out. For me, the wysiwyg was adding 2 spaces so this is what worked:
  `<?php
  if ($row->id_info_for_display_33 !== '  '  && !empty($row->id_info_for_display_33)) {
      print $row->display_name . ", " . $row->id_info_for_display_33;
  }
  else {
      print $row->display_name;
  }
  ?>`
Answers.UserDisplayName: Daniel Strum
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-29T14:56:25.437Z
Answers.LastActivityDate: 2015-06-29T14:56:25.437Z
Answers.UserDisplayName: Ghost
Body: <p>I am using a global php field in drupal views to display a list of names. If the contact record has extra info in a custom note (rich text editor) field, I want to display "name, info". If there is no extra info, I just want to display "name". This is what I am using as the output code of the global php field:</p>
  
  <pre><code>&lt;?php
  if (!empty($row-&gt;id_info_for_display_33)) {
      print $row-&gt;display_name . ", " . $row-&gt;id_info_for_display_33;
  }
  else {
      print $row-&gt;display_name;
  }
  ?&gt;
  </code></pre>
  
  <p>It seems that the custom field is never really empty unless it is a record that was created before the custom field was added. Even then, if I then edit that record, the custom field is no longer empty and the display ends up as "name,".</p>
  
  <p>Any ideas on what logic will accomplish this?</p>
  
  <p>Civi 4.6.2</p>
  
  <p>Drupal 7.38</p>
  
  <p>Views 7-3.11</p>
  
  <p>Thanks!</p>
  
Tags: <drupal-views>
Title: If "!empty" on custom note field in Drupal Views, Global PHP field
ThreadText: # If "!empty" on custom note field in Drupal Views, Global PHP field
  
  (Asked by: username_0 on 2015-06-29)
  
  I am using a global php field in drupal views to display a list of names. If the contact record has extra info in a custom note (rich text editor) field, I want to display "name, info". If there is no extra info, I just want to display "name". This is what I am using as the output code of the global php field:
  id_info_for_display_33)) {
      print $row->display_name . ", " . $row->id_info_for_display_33;
  }
  else {
      print $row->display_name;
  }
  ?>
  
  It seems that the custom field is never really empty unless it is a record that was created before the custom field was added. Even then, if I then edit that record, the custom field is no longer empty and the display ends up as "name,".
  Any ideas on what logic will accomplish this?
  Civi 4.6.2
  Drupal 7.38
  Views 7-3.11
  Thanks!
  
  **Tags:** drupal-views
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-29. Score: 3 | Accepted answer
  
  Looks like the CiviCRM is adding a space ' ' (may be because of CKEditor) into the custom table column , even though you leave it empty when adding/editing the record. 
  You can see it if you do var_dump of the variable. See below screenshot
  
  So the below logic should work in this case. 
  id_info_for_display_33 !== ' '  && !empty($row->id_info_for_display_33)) {
      print $row->display_name . ", " . $row->id_info_for_display_33;
  }
  else {
      print $row->display_name;
  }
  ?>
  
  Give it a try.
  
  > **Comments:**
  > **username_0**: Thanks... This def helped me out. For me, the wysiwyg was adding 2 spaces so this is what worked: `<?php if ($row->id_info_for_display_33 !== '  '  && !empty($row->id_info_for_display_33)) {     print $row->display_name . ", " . $row->id_info_for_display_33; } else {     print $row->display_name; } ?>`  
  
  ---
  
  