Answers.Body: <p>I've added a Views relationship to the CiviCRM Entity project that will allow you to do this. </p>
  
  <p>You must also enable the sub-module, CiviCRM Entity Views Extras.</p>
  
  <p>It is in the 7.x-2.x-dev as of Jul 7 2018, and will be included in the next release (2.2)</p>
  
  <p>Once you have the two modules installed, you will be able to add a Views Relationship titled "CiviCRM Member: Membership Type" to your View listing contacts. </p>
  
  <p>Once that Views relationship is in place, all the properties of the membership type table, including the membership type description will be available to include in your view. </p>
  
  <p>Here's export code for an example View that you can import to see for yourself:</p>
  
  <pre><code>$view = new view();
  $view-&gt;name = 'contact_view_with_membership_type_description';
  $view-&gt;description = '';
  $view-&gt;tag = 'default';
  $view-&gt;base_table = 'civicrm_contact';
  $view-&gt;human_name = 'Contact View with Membership Type Description';
  $view-&gt;core = 7;
  $view-&gt;api_version = '3.0';
  $view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  
  /* Display: Master */
  $handler = $view-&gt;new_display('default', 'Master', 'default');
  $handler-&gt;display-&gt;display_options['title'] = 'Contact View with Membership Type Description';
  $handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
  $handler-&gt;display-&gt;display_options['access']['type'] = 'none';
  $handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
  $handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
  $handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
  $handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
  $handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
  $handler-&gt;display-&gt;display_options['style_plugin'] = 'table';
  /* Relationship: CiviCRM Member: Membership Type */
  $handler-&gt;display-&gt;display_options['relationships']['civicrm_membership_type']['id'] = 'civicrm_membership_type';
  $handler-&gt;display-&gt;display_options['relationships']['civicrm_membership_type']['table'] = 'civicrm_membership';
  $handler-&gt;display-&gt;display_options['relationships']['civicrm_membership_type']['field'] = 'civicrm_membership_type';
  /* Field: CiviCRM Contacts: Contact ID */
  $handler-&gt;display-&gt;display_options['fields']['id']['id'] = 'id';
  $handler-&gt;display-&gt;display_options['fields']['id']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['fields']['id']['field'] = 'id';
  /* Field: CiviCRM Membership Type: Membership Type Description */
  $handler-&gt;display-&gt;display_options['fields']['description']['id'] = 'description';
  $handler-&gt;display-&gt;display_options['fields']['description']['table'] = 'civicrm_membership_type';
  $handler-&gt;display-&gt;display_options['fields']['description']['field'] = 'description';
  $handler-&gt;display-&gt;display_options['fields']['description']['relationship'] = 'civicrm_membership_type';
  /* Filter criterion: CiviCRM Member: Membership ID */
  $handler-&gt;display-&gt;display_options['filters']['id']['id'] = 'id';
  $handler-&gt;display-&gt;display_options['filters']['id']['table'] = 'civicrm_membership';
  $handler-&gt;display-&gt;display_options['filters']['id']['field'] = 'id';
  $handler-&gt;display-&gt;display_options['filters']['id']['operator'] = 'not empty';
  
  /* Display: Page */
  $handler = $view-&gt;new_display('page', 'Page', 'page');
  $handler-&gt;display-&gt;display_options['path'] = 'contact-view-with-membership-type-description';
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-08T22:00:50.223Z
Answers.Text: Nice. Was there going to be a link or an attachment for the 'example code'? Maybe you overlooked it
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-08T22:05:38.650Z
Answers.Text: updated answer to include the import code....
Answers.UserDisplayName: jackrabbithanna
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-24T00:21:07.280Z
Answers.Text: Thanks for that @jackrabbithanna. The CiviCRM Entity project was my first stop but I got there too early. If I were to run into this issue again, I'll definitely use it.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-08T03:11:06.413Z
Answers.LastActivityDate: 2018-07-08T22:05:20.607Z
Answers.LastEditDate: 2018-07-08T22:05:20.607Z
Answers.UserDisplayName: jackrabbithanna
Answers.Body: <p>I'm just following up in case someone else decides runs into the same sort of requirements. </p>
  
  <p>The solution was to create a helper module that created a pseudo-calculated field using hook_field_views_data() to declare the field and make it available. Then it used a field handler to run a switch statement to render the appropriate description for the membership level in question.</p>
  
  <p>It required very little code to pull off.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-28T00:58:40.697Z
Answers.LastActivityDate: 2018-06-28T00:58:40.697Z
Answers.UserDisplayName: Andrew Wasson
Answers.Body: <p>Ah yes - many label type fields don't have Views Integration. Since it is a label and presumably not likely to change I would add it to the View myself - For example: as a legend in the Header (or Footer);</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-15T19:38:53.217Z
Answers.Text: I assume this needs to be dynamic based on the Membership Type which the member has
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-15T20:16:54.783Z
Answers.Text: A Members Search page sounds like a directory in which case the results may be a number of members with different membership types; a legend in the Header (or Footer) would work well; bonus points for colour coding :-)
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-16T00:19:36.100Z
Answers.Text: ah. got you. yes explaining all relevant Member Types in header sounds reasonable work around (but having this in Views is the fix). Andrew - sing out if you want to fund some developer support to get this added in to Views. I expect it is ~20-30 mins to fix
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-25T00:14:31.130Z
Answers.Text: Thanks folks. Peter is correct in that we do want to have this in views. I was hoping it would be something plug and play but I'm ok with rolling up my sleeves. Peter, I'll Ping you offline if I need to send it your way for development.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-25T12:13:44.057Z
Answers.Text: Hi Andrew - it can already be done in Views - as is - you can create the Header in Views or Footer in Views and if you want it as a Column in Views then you can use a Global txt field in Views with Views PHP. Unless the descriptions are going to be changing frequently - that’s a now/no dev solution
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-08T03:24:21.217Z
Answers.Text: Thanks @KarinG-SemperIT. I had considered Views PHP but I've decided not to use them anymore unless there's no other viable options. For this job I decided to build a custom module to expose a custom ['civicrm_contact']['custom_views_field'] that acquires the membership ID and passes it to a switch statement in the handler that provides the associated description.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-15T17:55:11.200Z
Answers.LastActivityDate: 2018-04-15T17:55:11.200Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>I have built a Members Search page using a CiviCRM Contact View in Drupal 7 and I would like to render the Description field of the membership type for the contacts that are returned. This data doesn't appear to be available out of the box so I looked at the CiviCRM Entity module, however that doesn't seem to expose the description. What sort of approach should I take? </p>
  
Tags: <drupal><drupal-views>
Title: Can we expose the membership description field within a Drupal View
ThreadText: # Can we expose the membership description field within a Drupal View
  
  (Asked by: username_0 on 2018-04-15)
  
  I have built a Members Search page using a CiviCRM Contact View in Drupal 7 and I would like to render the Description field of the membership type for the contacts that are returned. This data doesn't appear to be available out of the box so I looked at the CiviCRM Entity module, however that doesn't seem to expose the description. What sort of approach should I take?
  
  **Tags:** drupal, drupal-views
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2018-07-08. Score: 2
  
  I've added a Views relationship to the CiviCRM Entity project that will allow you to do this. 
  You must also enable the sub-module, CiviCRM Entity Views Extras.
  It is in the 7.x-2.x-dev as of Jul 7 2018, and will be included in the next release (2.2)
  Once you have the two modules installed, you will be able to add a Views Relationship titled "CiviCRM Member: Membership Type" to your View listing contacts. 
  Once that Views relationship is in place, all the properties of the membership type table, including the membership type description will be available to include in your view. 
  Here's export code for an example View that you can import to see for yourself:
  $view = new view();
  $view->name = 'contact_view_with_membership_type_description';
  $view->description = '';
  $view->tag = 'default';
  $view->base_table = 'civicrm_contact';
  $view->human_name = 'Contact View with Membership Type Description';
  $view->core = 7;
  $view->api_version = '3.0';
  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  
  /* Display: Master */
  $handler = $view->new_display('default', 'Master', 'default');
  $handler->display->display_options['title'] = 'Contact View with Membership Type Description';
  $handler->display->display_options['use_more_always'] = FALSE;
  $handler->display->display_options['access']['type'] = 'none';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'full';
  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
  $handler->display->display_options['style_plugin'] = 'table';
  /* Relationship: CiviCRM Member: Membership Type */
  $handler->display->display_options['relationships']['civicrm_membership_type']['id'] = 'civicrm_membership_type';
  $handler->display->display_options['relationships']['civicrm_membership_type']['table'] = 'civicrm_membership';
  $handler->display->display_options['relationships']['civicrm_membership_type']['field'] = 'civicrm_membership_type';
  /* Field: CiviCRM Contacts: Contact ID */
  $handler->display->display_options['fields']['id']['id'] = 'id';
  $handler->display->display_options['fields']['id']['table'] = 'civicrm_contact';
  $handler->display->display_options['fields']['id']['field'] = 'id';
  /* Field: CiviCRM Membership Type: Membership Type Description */
  $handler->display->display_options['fields']['description']['id'] = 'description';
  $handler->display->display_options['fields']['description']['table'] = 'civicrm_membership_type';
  $handler->display->display_options['fields']['description']['field'] = 'description';
  $handler->display->display_options['fields']['description']['relationship'] = 'civicrm_membership_type';
  /* Filter criterion: CiviCRM Member: Membership ID */
  $handler->display->display_options['filters']['id']['id'] = 'id';
  $handler->display->display_options['filters']['id']['table'] = 'civicrm_membership';
  $handler->display->display_options['filters']['id']['field'] = 'id';
  $handler->display->display_options['filters']['id']['operator'] = 'not empty';
  
  /* Display: Page */
  $handler = $view->new_display('page', 'Page', 'page');
  $handler->display->display_options['path'] = 'contact-view-with-membership-type-description';
  
  > **Comments:**
  > **username_2**: Nice. Was there going to be a link or an attachment for the 'example code'? Maybe you overlooked it  
  > **username_1**: updated answer to include the import code....  
  > **username_0**: Thanks for that @username_1. The CiviCRM Entity project was my first stop but I got there too early. If I were to run into this issue again, I'll definitely use it.  
  
  ---
  
  ### Answer by username_0 on 2018-06-28. Score: 1
  
  I'm just following up in case someone else decides runs into the same sort of requirements.
  
  The solution was to create a helper module that created a pseudo-calculated field using hook\_field\_views\_data() to declare the field and make it available. Then it used a field handler to run a switch statement to render the appropriate description for the membership level in question.
  
  It required very little code to pull off.
  
  
  ---
  
  ### Answer by username_3 on 2018-04-15. Score: 1
  
  Ah yes - many label type fields don't have Views Integration. Since it is a label and presumably not likely to change I would add it to the View myself - For example: as a legend in the Header (or Footer);
  
  > **Comments:**
  > **username_2**: I assume this needs to be dynamic based on the Membership Type which the member has  
  > **username_3**: A Members Search page sounds like a directory in which case the results may be a number of members with different membership types; a legend in the Header (or Footer) would work well; bonus points for colour coding :-)  
  > **username_2**: ah. got you. yes explaining all relevant Member Types in header sounds reasonable work around (but having this in Views is the fix). Andrew - sing out if you want to fund some developer support to get this added in to Views. I expect it is ~20-30 mins to fix  
  > **username_0**: Thanks folks. Peter is correct in that we do want to have this in views. I was hoping it would be something plug and play but I'm ok with rolling up my sleeves. Peter, I'll Ping you offline if I need to send it your way for development.  
  > **username_3**: Hi Andrew - it can already be done in Views - as is - you can create the Header in Views or Footer in Views and if you want it as a Column in Views then you can use a Global txt field in Views with Views PHP. Unless the descriptions are going to be changing frequently - that’s a now/no dev solution  
  > **username_0**: Thanks @KarinG-SemperIT. I had considered Views PHP but I've decided not to use them anymore unless there's no other viable options. For this job I decided to build a custom module to expose a custom ['civicrm_contact']['custom_views_field'] that acquires the membership ID and passes it to a switch statement in the handler that provides the associated description.  
  
  ---
  
  