Body: <p>This is a bit of a long running annoyance that I'd like to overcome one way or another that involves rendering a CiviCRM Contacts View with a <strong>CiviCRM Contacts: Text Link field</strong> in the results.</p>
  <p>Most of the Drupal/CiviCRM websites I build will have a roster or series of rosters that list out CiviCRM Contacts. To make it easy for the Admins to edit a contact from a roster, I expose a <strong>CiviCRM Contacts: Text Link field</strong> in the results that is configured to go to the Contact Edit page.</p>
  <p>The problem is that when a non-Admin views the roster page, CiviCRM and/or Views doesn't do a good job of sending an empty field to the view. rather, it stumbles and I get a large listing of PHP Notices as folllows:</p>
  <blockquote>
  <p>Notice: Undefined variable: custom_link in
  civicrm_handler_field_link_contact-&gt;render_link() (line 118 of
  /sites/all/modules/civicrm/drupal/modules/views/civicrm/civicrm_handler_field_link_contact.inc).</p>
  </blockquote>
  <p>I'm not sure what the best approach would be. Create an issue in the CiviCRM Issue Queue or the Drupal Views issue queue and add some error trapping to civicrm_handler_field_link_contact.inc or perhaps there is already a workaround.</p>
  <p>Has anyone else run into this? I've experienced this on every version of Drupal 7 and CiviCRM.</p>
  <p>Cheers,
  Andrew</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-02T02:07:51.033Z
Comments.Text: FYI, I've added a conditional to squelch the PHP notice and may issue a patch to the CiviCRM issue queue.
Comments.UserDisplayName: Andrew Wasson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-02T04:02:05.993Z
Comments.Text: why does a non-Admin get to see the same list with the same links? can't you give each type of user a different display? or am i sidestepping an issue that you want to deal with head on?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-02T22:51:55.053Z
Comments.Text: Hi Peter, The lists are public information. For ease of administering, I equip all Drupal Views with action links so that Admins can quickly and effectively make updates and corrections on the fly, when they see them. Typically Drupal Views render or hide admin fields correctly. In this case the civicrm_handler_field_link_contact->render_link() method is missing a conditional to escape the non existent object.
Comments.UserDisplayName: Andrew Wasson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-04T04:04:54.927Z
Comments.Text: Just an FYI: It seems the bug is in the switch statement. I've got it fixed on my system so I'll be creating a fork and a PR for it.
Comments.UserDisplayName: Andrew Wasson
Tags: <drupal-views><drupal-7>
Title: Approach to hiding the CiviCRM Contacts: Text Link field from non admins in a Drupal view
ThreadText: # Approach to hiding the CiviCRM Contacts: Text Link field from non admins in a Drupal view
  
  (Asked by: username_0 on 2021-11-02)
  
  This is a bit of a long running annoyance that I'd like to overcome one way or another that involves rendering a CiviCRM Contacts View with a **CiviCRM Contacts: Text Link field** in the results.
  
  Most of the Drupal/CiviCRM websites I build will have a roster or series of rosters that list out CiviCRM Contacts. To make it easy for the Admins to edit a contact from a roster, I expose a **CiviCRM Contacts: Text Link field** in the results that is configured to go to the Contact Edit page.
  
  The problem is that when a non-Admin views the roster page, CiviCRM and/or Views doesn't do a good job of sending an empty field to the view. rather, it stumbles and I get a large listing of PHP Notices as folllows:
  
  > Notice: Undefined variable: custom\_link in
  > civicrm\_handler\_field\_link\_contact->render\_link() (line 118 of
  > /sites/all/modules/civicrm/drupal/modules/views/civicrm/civicrm\_handler\_field\_link\_contact.inc).
  
  I'm not sure what the best approach would be. Create an issue in the CiviCRM Issue Queue or the Drupal Views issue queue and add some error trapping to civicrm\_handler\_field\_link\_contact.inc or perhaps there is already a workaround.
  
  Has anyone else run into this? I've experienced this on every version of Drupal 7 and CiviCRM.
  
  Cheers,
  Andrew
  
  **Tags:** drupal-views, drupal-7
  
  > **Comments:**
  > **username_0**: FYI, I've added a conditional to squelch the PHP notice and may issue a patch to the CiviCRM issue queue.  
  > **username_1**: why does a non-Admin get to see the same list with the same links? can't you give each type of user a different display? or am i sidestepping an issue that you want to deal with head on?  
  > **username_0**: Hi Peter, The lists are public information. For ease of administering, I equip all Drupal Views with action links so that Admins can quickly and effectively make updates and corrections on the fly, when they see them. Typically Drupal Views render or hide admin fields correctly. In this case the civicrm_handler_field_link_contact->render_link() method is missing a conditional to escape the non existent object.  
  > **username_0**: Just an FYI: It seems the bug is in the switch statement. I've got it fixed on my system so I'll be creating a fork and a PR for it.  
  
  ---
  
  ## 0 answers
  
  