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) »
  • Adding a Tab to Contact View in CiviCRM 2.1
Pages: [1]

Author Topic: Adding a Tab to Contact View in CiviCRM 2.1  (Read 3912 times)

FredJones

  • Guest
Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 04:02:38 am
We have the "Adding a Drupal page as a Tab to the CiviCRM Contacts page" in the wiki: http://wiki.civicrm.org/confluence/display/CRMDOC/Adding+a+Drupal+page+as+a+Tab+to+the+CiviCRM+Contacts+page but this method will not work in Drupal 6.x/CiviCRM 2.1.x.

I am trying to achieve this, but no luck thus far.

Can anyone provide any pointers?

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: Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 06:27:04 am

can you give us more specific details on what you have done so far and what is not working. Please cut-n-paste the lines of code etc

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

FredJones

  • Guest
Re: Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 06:35:59 am
Well I don't really have any code to share. CRM_Utils_Menu (which Gordon used originally) doesn't appear to exist in 2.1. In 2.0 I see a CRM_Core_Menu::add but that doesn't exist in 2.1 either as far as I can see.

And the whole approach of a conditional menu item works fine for Drupal 5, but for Drupal 6, menu items are cached I believe and so mymodule_menu is not run for each fresh page load, so I don't see a way to test there for the URL beginning with 'civicrm/contact/view'

I thought instead to add the tab in mymodule_init (because that is run each page load), but I don't see what function to use to add it--I am looking at CRM\Core\Menu.php but there's no add() there.

I can't say that I even understand much of the code there. On line 71 of that file $coreMenuFiles is defined but unless I am missing something, that variable is never used anywhere in the entire CiviCRM code base.

In short, I am a bit lost how to get started...

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: Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 10:44:25 am
WOuld it help if you spelled out what you are trying to achieve in case there is now another/easier way of achieving same?
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

FredJones

  • Guest
Re: Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 10:49:06 am
The actual task at hand is "private tags," meaning that each user can create his own set of tags which will be either private to his user account or to his group ("group" will be defined more precisely later). He can then assign those tags to CiviCRM contacts and view them. No one aside from him (or his group) can see his tags nor their assignment to contacts.

The way I thought to approach this is to store the tags in a custom table in the Drupal 6 DB, normalized by user id. The CRUD of them is from a custom module and the main feature, i.e. the assignment (and viewing/unassignment) of them to contacts, I would ideally put in a custom tab on the contact record page.

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: Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 12:07:45 pm

check: http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification

specifically: civicrm_hooks_links, case 'tabs.contact.activity'

you need to ensure that the url you pass in returns a valid html snippet for the tab to render. You should use firebug and see examples of what the other tab urls return

Note that we've changed that hook in 2.2 and created a seperate hook for tabs (so users can suppress / modify / rearrange tabs as needed)

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

FredJones

  • Guest
Re: Adding a Tab to Contact View in CiviCRM 2.1
December 03, 2008, 01:49:50 pm
Perfect--works like a charm.

> Note that we've changed that hook in 2.2

OK, I will bear that in mind when we upgrade.

Thank you very much!

lorenzo

  • Guest
Re: Adding a Tab to Contact View in CiviCRM 2.1
February 11, 2009, 01:58:45 pm
Hello,

I took the code below from the civicrm hook api page which adds a new tab. I want to link the tab to the drupal user edit page like this: URL = index.php?q=user/1/edit but I don't know how to work with the snippets? Firebug didnt't help.

Hints appreciated, thanks!


function add_drupaluser_tab_civicrm_links( $op, $objectName, $objectId ) {
  $links = array();
  switch ($objectName) {
    case 'Contact':
      switch ($op) {
        case 'tabs.contact.activity':
          // Adds a new tab.
          $links[] = array(
            'id' => 'myId',
            'title' => 'tabname',
            'url' => ' URL ', // problem with snippets
            'weight' => 10,
          );
          break;
      }
  }
  return $links;
}

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding a Tab to Contact View in CiviCRM 2.1

This forum was archived on 2017-11-26.