Since I tried out the widget, I figured I could use some way to see the data in view mode. So I've added a bit of code here to theme the contact pointed to by field_contact_ref.

Right now, I'm just taking the default profile and applying it. It may make sense to allow the user to set the profile as part of the configuration of the slot as well, since you might want to display more than one profile of the same contact in a CCK data type.

So here's a patch to show how to do it, anyway.

CommentFileSizeAuthor
civicrmdata-contact-view.patch.txt1.48 KBTorenware

Comments

mfredrickson’s picture

I like the basic idea. Can we refactor your themeing code to just take a pid (or profile object) and a contact id (or contact object) and return some HTML?

The node factory stuff is a little weird. For example, it works great for my admin user, but d/n work for anon users. I suspect this is because we are trying to publish nodes by UID = 0? Just a theory, I haven't troubled shot the code enough to know for sure.

-M

Torenware’s picture

Mark,

I'm looking into this, but my sense is that probably the node factory code is not the problem; the problem may be with CiviCRM's access code, which is a PITA above and beyond my code.

Check what happens if you set the "View All Contacts" permission for the Anonymous user (way too much access, but there you go). If you get good behavior with that permission set up, then this may be yet another opportunity to ask Lobo and Dave Greenberg to look into their code.

I will look at factoring the code, in any event.

Torenware’s picture

Mark,

Did a bit of refactoring. Here's how you'd do view with the new theming routine:

/**
 * Implementation of hook_field().
 */
function civicrmdata_field($op, &$node, $field, $a2, $a3, $a4) {
  global $user;
  if ($op == 'view') {
    //error_log("field invoke view");
   switch ($field['field_name']) {
     case 'field_contact_ref':
       if ($node->field_contact_ref['crmid']) {
         $pid = civinode_get_default_profile_id($user->uid);
				 $cid = $node->field_contact_ref['crmid'];
         $output = theme('crm_profile_cid', $pid, $cid);
         return $output;
       }
   }
  }
}


mfredrickson’s picture

Status: Needs review » Fixed

Thanks. I've committed the new theming system.

Anonymous’s picture

Status: Fixed » Closed (fixed)