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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Adding relationships to contact summary tab
Pages: [1]

Author Topic: Adding relationships to contact summary tab  (Read 771 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Adding relationships to contact summary tab
August 29, 2011, 08:05:09 am
There is an existing thread about this I couldn't find. This is my apiv3 code (just updated) to add contact relationships to the summary (specified types only).

Note that adding $rel.custom_1 in the below should add custom data field #1 data

Code: [Select]
Index: templates/CRM/Contact/Page/View/Summary.tpl
===================================================================
--- templates/CRM/Contact/Page/View/Summary.tpl (revision 35982)
+++ templates/CRM/Contact/Page/View/Summary.tpl (working copy)
@@ -242,6 +242,28 @@
                         <div class="clear"></div>
                     </div><!-- #contact_panel -->
 
+{crmAPI entity="relationship" action="get" var="relationships" contact_id=$contactId relationship_type_id=1}
+{if $relationships.values}
+ <div class="contact_panel">
+<div class="contactCardRight">
+ <table>
+{foreach from=$relationships.values item=rel}
+{if $rel.relationship_type_id eq 1 || $rel.relationship_type_id eq 21}
+<tr id="rel_{$rel.cid}">
+{if $rel.is_active == 0 }
+   <td class="label">former</td>
+{else}
+<td class="label">{$rel.relation}</td>
+{/if}
+<td class="name"><a href="/civicrm/contact/view?cid={$rel.cid}&reset=1">{$rel.name}</a></td>
+</tr>
+{/if}
+{/foreach}
+</table>
+</div>
+</div>
+{/if}
+
  {if $address}
                     <div class="contact_panel">
                         {foreach from=$address item=add key=locationIndex}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Adding relationships to contact summary tab
August 29, 2011, 09:22:50 am
So, one for you X+

I stuck this in there

{crmAPI entity="contact" action="get" var="contacts" id=$rel.cid return_custom_1=1}
{$contacts|print_r}

Looks like 
return.custom_1=1
is invalid?

what is the format for your return =array()?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Adding relationships to contact summary tab
August 29, 2011, 01:26:24 pm
Hi,

I think I did it as return="field1,field2,field3"

Not sure that the relationship api does handle custom fields and return. You can check in the API explorer.

X+

P.S. And a wise women told me to write a unit code if wanting to be sure it isn't broken in the next update ;)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Adding relationships to contact summary tab
August 29, 2011, 03:57:30 pm
Aha - there is a unit test for the php only approach..... but not too sure about smarty.

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Adding relationships to contact summary tab

This forum was archived on 2017-11-26.