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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • CCK Select Field Values - Override with Contacts from CiviCRM Group
Pages: [1]

Author Topic: CCK Select Field Values - Override with Contacts from CiviCRM Group  (Read 6833 times)

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
CCK Select Field Values - Override with Contacts from CiviCRM Group
April 10, 2009, 04:09:32 pm
I need to override the Allowed Values of a Select Field I created in CCK with a piece of code that retrieves from CiviCRM the contacts from a specific group. I have the code to retrieve them, but then in the select list it appears only 1 item: "ARRAY". This is the code:

Code: [Select]
    civicrm_initialize();
    require_once 'api/v2/Contact.php';
    $groupId = 5;
    $params = array( 'group' => array( $groupId => 1),                                                                                                         
                                 'return.sort_name'    => 1                                                                                                       
                               );                                                                                                                               
    $contacts = civicrm_contact_search( $params );                                                                                                     
    return ($contacts);

... but I need the user to be able to choose between the retreived contacts. How can I get a valid "keyed array"..? I think this is a PHP/Drupal question, but I would appreciate any insights.

Thanks in advance.
Alex.
« Last Edit: April 10, 2009, 04:18:33 pm by alextronic »

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 11, 2009, 09:46:07 am
OK I did it!  :)

It was something like this:

Code: [Select]
    civicrm_initialize();
    require_once 'api/v2/Contact.php';
    $groupId = 5;
    $params = array( 'group' => array( $groupId => 1),
                                 'return.sort_name'    => 1
                               );
    $values = array('contact_id', 'sort_name');
    $contacts = civicrm_contact_search( $params);

$result = array_values($contacts);
$n=0;
$final = array();

foreach ($result as $key => $value) {
$final[$n] = $result[$n]['sort_name'];
$n++;
}

return($final);

...I'm sorry to fill this forum with n00b's issues, but at least I did it!!
Thank you anyway

Alex

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 11, 2009, 02:05:18 pm
Only just beginning to explore what is possible with pulling data through to be exposed in Drupal. Have been exploring Views rather than CCK - does the above lend itself to extending what is possible in Views to exposing contacts in particular Groups?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 12, 2009, 03:00:52 pm
I've never tried to pull CiviCRM data using Views, so I don't know if the above can extend what is possible with that module. Before I started working I pondered which could be the best way to do what I needed and everything was leading me to CCK -- I use 'ContentTemplates' which are provided with a handy list of PropertyNames/Values. When I manage the fields for my ContentTypes, I create a way to let the user search, get or even create CiviCRM information via the APIs.
Lots of things are possible this way.
« Last Edit: April 12, 2009, 03:04:02 pm by alextronic »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 12, 2009, 10:39:51 pm
Alex - I think it would help stimulate others to push things forward and experiment if you could share the requirements / use case(s) you are building this for.

Also, Lobo on our team is working on some CCK integration - don't know the details but you could follow this issue:
http://issues.civicrm.org/jira/browse/CRM-4349

(unless he and you are already working together on IRC etc. :-) )
Protect your investment in CiviCRM by  becoming a Member!

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 13, 2009, 02:12:46 pm
Sure I will, as soon as I have it all sorted out in my mind...  ???
Will try Lobo's approach to CCK (can't get to install the module in http://fisheye.civicrm.org/viewrep/CiviCRM/branches/v2.2/drupal/modules/civicrm_cck)
On the other hand, now I'm starting to look into Views.
(BTW, sorry for my english)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 13, 2009, 02:55:55 pm

briefly, IMO

CCK = create and inject data into the system

Views2 = view above data in different formats

our current CCK integration module is a VERY simple contact reference module. Would be great for someone in the community to create a "CCK Contact Creation Module" so folks can use CCK / Drupal to create CiviCRM Contacts via CCK

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 13, 2009, 04:12:36 pm
Quote
CCK = create and inject data into the system
Views2 = view above data in different formats

I was at the point of starting to realise this. Regarding Views module, I activated it a few hours ago because of an issue that motivated me to post another question in this forum (custom fields in the creation of contribution pages); I'm trying to make a Drupal node that serves as a Search of contribution pages --with select lists pulling data from civiCRM and send the values to an API-driven node that returns the filtered results-- ...maybe I could use something like CRM_Core_DAO::commonRetrieve( 'CRM_Contribute_DAO_ContributionPage', $params, $values ); to do this (a method I don't understand fully) so I'm still struggling, any help is appreciated. Searching Organizations or Contacts is way easier and got it figured out already (I think)  :P So I was wondering, is there a way to retrieve a list of Contribution Pages (again, not contributions) through Views module?

Anyway, if I get to any useful insight I will sure post it here-- even though I'm not Master indeed. I'm really excited with all this stuff.


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 13, 2009, 04:18:40 pm

Contribution Pages have not yet been exposed to Views2. You will need to add the views2 integration code and handlers. Lots of examples for other civicrm tables in drupal/modules/views

If you do add the contribution page info, please submit your changes

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
April 13, 2009, 04:24:37 pm
GREAT.

I'll work on that. Thank you so much.

locomo

  • I’m new here
  • *
  • Posts: 4
  • Karma: 2
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
May 22, 2009, 11:07:31 pm
just curious if anyone is working on the "CCK Contact Creation Module" idea mentioned above - this would come in really handy
« Last Edit: May 22, 2009, 11:09:11 pm by locomo »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
May 23, 2009, 07:48:03 am

This would have been announced if someone did work on it and come up with a module

If this would be useful to you, please do consider stepping up and contributing. If you are not a developer consider hiring someone or getting a group of people to sponsor this functionality. Wishing it would happen does not make it happen :(

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

locomo

  • I’m new here
  • *
  • Posts: 4
  • Karma: 2
Re: CCK Select Field Values - Override with Contacts from CiviCRM Group
May 23, 2009, 09:23:21 am
thanks lobo

i'm new to developing for civicrm - but i'll take a look and see if i can jump in somehow

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • CCK Select Field Values - Override with Contacts from CiviCRM Group

This forum was archived on 2017-11-26.