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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Displaying specific roles in an organization
Pages: [1]

Author Topic: Displaying specific roles in an organization  (Read 764 times)

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Displaying specific roles in an organization
March 03, 2012, 12:18:02 pm
Hi,
I want to track certain roles for a group of organizations and display them in the summary tab.  Eg for schools, we want to display roles like headteacher & deputy heads  on the summary tab.  I'm thinking we would have relationships for each of these and then somehow change the summary to search the relationships and display the ones of interest.  The relationships tab would potentially have many other relationships that we don't want in the summary.

This seems like it might be a fairly common need - is there any existing functionality to support this? 
If not, are relationships and hooks a good way to go?  And if so, any pointers to existing hook code I could base this on?

Thanks!

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: Displaying specific roles in an organization
March 03, 2012, 03:24:50 pm

Dont think this has been done, but seems like this has come up in the past

You'll need to use the pageRun hook on the summary page to implement it.

The code here:

http://svn.civicrm.org/sfschool/branches/v2.2/drupal/sfschool/sfschool.module

might help. It displays the children of the parents on a profile page, so you can use a similar concept

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

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: Displaying specific roles in an organization
March 04, 2012, 12:24:31 pm
not sure if this is what you are after but this addition to the CRM/Contact/Page/View/Summary.tpl results in people with a particular relationship to a contact showing in the top right area of the Summary screen

this was inserted around line 245 on the version i am looking at

Code: [Select]
{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 10}
<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}
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

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Re: Displaying specific roles in an organization
March 12, 2012, 02:21:49 pm
Lobo, Pete
Many thanks for your responses.  Pete's code is very close to what I was looking for.  I have tweaked it a bit to display multiple relationships and moved it up above the email address to line 199 (v 4.1.1) of summary.tpl

Code: [Select]

{crmAPI entity="relationship" action="get" var="relationships" contact_id=$contactId relationship_type_id=1}
{if $relationships.values}
{assign var=display_rels value=','|explode:'2,12,24,13,14,15,16,17,18,19,20,21,22,23,32,25,26,27,28,29'}
{foreach from=$display_rels item=display_rel_id}
{foreach from=$relationships.values item=rel}
{if $rel.relationship_type_id eq $display_rel_id}
<tr id="rel_{$rel.cid}_{$display_rel_id}">
{if $rel.is_active == 0 }
<td class="label">Former {$rel.relation}</td>
{else}
<td class="label">{$rel.relation}</td>
{/if}
<td class="name">
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$rel.cid`"}" title="{$rel.display_name}">
{$rel.display_name}
</a>
</td>
</tr>
{/if}
{/foreach}
{/foreach}
{/if}

The list of relationships is not as long as it might suggest since that list of relationships includes different sub-types so only a selection of them are applicable for any given contact.  It works for both sides of the relationship without any specific work - eg when viewing the school's summary it shows the head teacher and when viewing the head teacher's summary it shows the school he/she is head of.

One small issue is that the background box for the relationship value is a little shorter than the rest of the table.  Where is that determined?

If we could pull the list of relationship id's from a query rather than hard-coded it would be more generally useful.  Any suggestions for where that could be stored?  Is it possible to add custom data to the relationship type itself (different to custom data stored in a relationship)?  Something like the ordering of Activity Type Options would be good since the display should be in the specified order.

From my limited understanding, it seems hooks have to be written specifically for the CMS, so modifying the template is more attractive since it is CMS-independent.  On the other hand, hooks are more powerful and can do more than just modify the display.  Is that right?

Any other suggestions for improvement?

aydun

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Displaying specific roles in an organization

This forum was archived on 2017-11-26.