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) »
  • Exposing a relationship on the Summary Tab
Pages: [1]

Author Topic: Exposing a relationship on the Summary Tab  (Read 409 times)

scrubba

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 2
  • CiviCRM version: 4.6.2
  • CMS version: Wordpress 4.2
Exposing a relationship on the Summary Tab
March 02, 2015, 09:01:32 pm
Hi

I'm a little new to this area - so would appreciate any pointers
A client wants to add a specific relationship to the Contact Summary Tab,
Basically its a community theatre - they list actors, and some have agents and some dont and they want that easy to see.
So I have Actors as Contact Type: Individual, and the Agents are Sub type of Organisations,
And then the relationship between them is "Agent is / Agent of" - which is relationship_type_id=15

So I have added the relationship and to which agent on the summary tab - right hand column - above Where tags are listed. No problems here - I found an older post Here:
http://forum.civicrm.org/index.php/topic,23684.msg99564.html#msg99564
Where PetedNZ helfully provides an example - and I used that code as the basis -
to over-ride the Summary.tpl - And all is working from the Individual side - The code I have ended up with is:

Code: [Select]
{crmAPI entity="relationship" action="get" var="relationships" contact_id=$contactId relationship_type_id=15 }
{if $relationships.values}
{foreach from=$relationships.values item=rel}
<div class="crm-label" id="rel_{$rel.cid}">

<td class="label">{$rel.relation}</td></div>
<div class="crm-content">                     
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$rel.cid`"}" title="{$rel.display_name}">
{$rel.display_name}</a>
</div>
                         
{/foreach}
{/if}

On my example Actor - the 'Agent is' displays in the right column, as does the Clickable name of the Agency in the right .

The problem I have is that when I click through to the Agent - The Agent ends up with a line by line list of all their 'Agent of' connections - which I don't want, as some agents have multiple actors so that would get out of control. So I only need this to display in individuals summarys, not the organisation side of the relationship.

So my issue is how to limit this to the Individual summarys, not the Agent / Organisation side.
I figure I either have to filter using parameter contact_type.id=1 - which I cant quite work out
Or filter using parameter relationship_type.name_a_b="Agent is"

I have had a play with the API explorer and had a try with chaining the ContactType entity but no success so far.
Any pointers?

Thanks
Chris (Scrubba)





 

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: Exposing a relationship on the Summary Tab
March 02, 2015, 10:35:17 pm
Hey chris - you should find what you need in here as we do now have options to only show the Rel either from A or B (or Org or whatever it is)

https://github.com/eileenmcnaughton/nz.co.fuzion.relationshipblock
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

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Exposing a relationship on the Summary Tab
March 03, 2015, 05:19:21 am
I think your api call should say "contact_id_a" not "contact_id" as the param.
Try asking your question on the new CiviCRM help site.

scrubba

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 2
  • CiviCRM version: 4.6.2
  • CMS version: Wordpress 4.2
Re: Exposing a relationship on the Summary Tab
March 03, 2015, 08:10:10 pm
Thanks for the suggestions Pete and Coleman
Went with the Fuzion extension

Pete - for the purposes of polishing up the extension - if you ever needed to get around to it

 I just had to change a couple of things - in templates/RelationshipBlock.tpl
at the end of line 20 it read
Code: [Select]
</td><td 'class='crm-rel_block'>" }i needed to remove the single quote from before the "class"
Also had to alter the URL on line 23 so it would work with my Wordpress instance

And for my purposes - in RelationshipBlock.php
i changed the if else statement  - specifically First ContactType to 'Individual'
and diddled with the arrays to suit my Relationship ids ..

and Bob's your uncle - all working perfectly ..

Oh yeah - also it says in the Extension comments :
This module requires regions to be defined in summary.tpl.
Which seems to be no longer the case - it just adds the block under "Source" in the left region of the summary which suited me.

Thanks so much for sharing - and giving pointers..

Chris






Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Exposing a relationship on the Summary Tab
March 04, 2015, 05:57:47 am
scrubba why not submit a PR back to help improve their extension :)
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Exposing a relationship on the Summary Tab

This forum was archived on 2017-11-26.