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) »
  • How to add Relationship data to Summary tab?
Pages: [1]

Author Topic: How to add Relationship data to Summary tab?  (Read 3891 times)

syntetik

  • Guest
How to add Relationship data to Summary tab?
September 14, 2009, 05:08:01 pm
For a comfort I want to add Relationship block at the bottom of Summary tab. I know that one step is adding
Code: [Select]
{include file="CRM/Contact/Page/View/Relationship.tpl"} before last {/if} in template CRM\Contact\Page\View\Tabbed.tpl, but somehow I must create data for this include. I understand that these actions must be in hook_civicrm_buildForm(), but don't know which actions. Please help!

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: How to add Relationship data to Summary tab?
September 16, 2009, 04:52:36 am
To know what data to create check CRM/Contact/Page/View/Relationship.php file (for php code).

hook_civicrm_pageRun() hook would be appropriate, as summary tab view is a page view.

For a better example (hook implementation) check - http://svn.civicrm.org/sfschool/trunk/drupal/sfschool/sfschool.module.
« Last Edit: September 16, 2009, 04:57:14 am by Deepak Srivastava »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: How to add Relationship data to Summary tab?
September 16, 2009, 08:51:48 am
Easier:

create a custom template, and add

{crmAPI entity="relationship" action="get" var="relationships" contact_id=$cid}

Then you can display it the way you want, eg

{foreach from=$relationships.result item=rel}
<tr id="mep_{$rel.cid}">
{if $rel.is_active == 0 }
   <td>former</td>
{else}
<td>{$rel.relation}</td>
{/if}
<td class="name"><a href="/mep/{$rel.cid}">{$rel.name}</a></td>
<td ><a href="/country/{$rel.country_id}">{$rel.country}</a></td>
<td><a href="/party/{$rel.employer_id}">{$rel.organization_name}</a></td>
</tr>
{/foreach}

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: How to add Relationship data to Summary tab?
September 16, 2009, 08:58:16 am

this is truly an awesome and cool way of going things :)

that extension (crmAPI) is definitely great

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: How to add Relationship data to Summary tab?
September 16, 2009, 11:41:20 pm


Like it too;)

...and I suspect it will increase the number of people using the api and help improving it. That was with that that I realised my need to add a parameter to fetch only the active relationships.

On mepwatch, we have completely replaced the profiles by an external module using smarty and only the civicrm apis called from within the template, so we could mix more freely the relationships, contact datas and non civicrm datas. Works great, and makes it simplier to have nice urls, and to cache when we need it.

X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

syntetik

  • Guest
Re: How to add Relationship data to Summary tab?
September 17, 2009, 07:55:13 am
Thank you, guys!

I don't know crmAPI, so I copied and edited code from relationships.php into mymodule_civicrm_pageRun() hook and check page name, $links become an empty string, and zero assigned to $page->action. Include Relationship.tpl goes not before last {/if} as I said on first post (it appears on all tabs), but right after include CustomDataView.tpl.

About crmAPI - is it available without any additional code? Or must I install something?

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: How to add Relationship data to Summary tab?
September 17, 2009, 08:15:46 am
crmAPI is supported by CiviCRM v3.0.

To read more about crmAPI check - http://civicrm.org/node/599

Quote
as I said on first post (it appears on all tabs
You 'll need to hardcode the class name ($name) to make it appear on one tab only. Jump on irc for more details.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: How to add Relationship data to Summary tab?
March 23, 2011, 05:55:15 pm
Just implemented this - too easy! I took a look @ Kyle's presentation.

Here's how it looks as a patch - adding relationships to contact summary page (patched against 3.3.5 but with backported apiv3 http://forum.civicrm.org/index.php/topic,19205.0.html). Usual provisos apply about creating a custom templates directory. (NB not sure how to create the url so it handles clean & dirty urls - this is the clean url version)

Note that the api v3 relationship behaviour didn't seem quite right http://forum.civicrm.org/index.php/topic,19230.0.html & I suspect that contact_id_a will change to contact_id

Index: templates/CRM/Contact/Page/View/Summary.tpl
===================================================================
--- templates/CRM/Contact/Page/View/Summary.tpl   (revision 33171)
+++ templates/CRM/Contact/Page/View/Summary.tpl   (working copy)
@@ -241,6 +241,27 @@
 
                         <div class="clear"></div>
                     </div><!-- #contact_panel -->
+{crmAPI entity="relationship" action="get" var="relationships" contact_id_a=$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">


« Last Edit: March 27, 2011, 05:45:28 pm by Eileen »
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: How to add Relationship data to Summary tab?
March 24, 2011, 08:58:12 am
Glad you like it... and cool way of using the api, isn't it ? 

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: How to add Relationship data to Summary tab?
April 30, 2012, 10:54:04 am
@Eileen:

This API example works great for printing the contact(s) with certain important relationship(s) on the Summary page.  Thanks!  A little tweaking necessary

1. the ID# of the relationship type
2. contact_id_a becomes simply contact_id

but that is all.

Try CiviTeacher: the online video tutorial CiviCRM learning library.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to add Relationship data to Summary tab?

This forum was archived on 2017-11-26.