CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • using views to display members, and their business
Pages: [1]

Author Topic: using views to display members, and their business  (Read 1960 times)

adelewh

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
using views to display members, and their business
April 29, 2009, 10:19:40 pm
Hi there --
I'm using drupal 6.11, and views 2.5.... I'm painfully new to both.

Here's what I have set up:
  • I have civimembers with membership levels of business, nonprofit and individual.  With the levels of business and nonprofit, I have custom fields collecting the biz/nonproft name, website, address...
  • I have set up a view, filtering civicrm contributions with a status of complete, and also a type of member dues.... (this is displaying member names)

Here's what I want to do:
I want to show, in views, who is a member, and then if they are a business member or nonprofit member, the name of the business/nonprofit... and this is where I'm getting stuck.  Any ideas? 

thanks


DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: using views to display members, and their business
May 29, 2009, 07:39:29 am
Please take a look on this module: http://drupal.org/project/views_customfield

It allows to add custom php to each row of a views table. This is what I add to change contact's name to a drupal profile link only for those contacts who have a drupal profile:

Code: [Select]
<?php
     
global $user;
     
civicrm_initialize( );
     require_once 
'CRM/Core/BAO/UFMatch.php';
     
$name = check_plain($data->civicrm_contact_last_name) . " " .   check_plain($data->civicrm_contact_first_name) . " " . check_plain($data->civicrm_contact_middle_name);
     
$uf_id = CRM_Core_BAO_UFMatch::getUFId($data->id);
     if ((
$uf_id) & ($user->uid>0) & (user_access("access user profiles"))) {
        echo 
l( $name ,"user/".$uf_id);
     } 
     else {
        echo 
$name;
     }  
?>


You can write something like this to show some information if some conditions are true. And you have full access to CiviCRM API in this way.

Regards,
Danila

adelewh

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
Re: using views to display members, and their business
May 29, 2009, 10:16:52 am
Thanks Danila -- I'll give it a try!

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: using views to display members, and their business
May 30, 2009, 10:30:25 pm
Changed the code so that CiviCRM API is called only if user has enough rights. Could be faster (or not, if Views cache all information anyway).

Code: [Select]
<?php
     
global $user;
     
$name = check_plain($data->civicrm_contact_last_name) . " " . check_plain($data->civicrm_contact_first_name) . " " . check_plain($data->civicrm_contact_middle_name);
     if ((
$user->uid>0) & (user_access("access user profiles"))) {
         
civicrm_initialize( );
         require_once 
'CRM/Core/BAO/UFMatch.php';
         
         
$uf_id = CRM_Core_BAO_UFMatch::getUFId($data->id);
         if (
$uf_id) {
            echo 
l( $name ,"user/".$uf_id);
         } 
         else {
            echo 
$name;
         }
    }
    else {
       echo 
$name;
    } 
?>

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • using views to display members, and their business

This forum was archived on 2017-11-26.