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) »
  • Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
Pages: [1]

Author Topic: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?  (Read 678 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
November 08, 2014, 06:49:36 am
I am using the hook function civicrm_tabs to display some extra information on a new contact tab. My code worked under version 4.4.7, but when I upgraded to version 4.5.3, I started getting an error.   In 4.5, when I view a contact record I can see the new tab as expected. However when I click on the tab I get the error message  "Network Error:  Unable to reach the server. Please refresh this page in your browser and try again."   ( the label of the tab is fine, but the body of the tab is all white)   I also tried visiting the tab URL ( ie http://mygroup.org/civicrm/myspecialtab)  directly in  my browser, and that worked.

Is there an example of what to change for 4.5?

My code for the hook is:



Code: [Select]
mymodule_civicrm_tabs( &$tabs, $contactID ) {
 
 
    $url = CRM_Utils_System::url( 'civicrm/myspecialtab',
                                  "reset=1&snippet=1&force=1&cid=$contactID" );
    $tabs[] = array( 'id'    => 'mySupercoolTab',
                     'url'   => $url,
                     'title' => 'Special Tab',
                     'weight' => 300 );
}
« Last Edit: November 08, 2014, 07:05:48 am by epg »
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
November 08, 2014, 10:05:42 am
`snippet=1` is deprecated and the tab infrastructure no longer uses it. When fetching tab data from the server we now automatically append `snippet=json` to the url string, which fetches the markup as part of a structured json array.
This ought to happen automatically unless your civicrm/myspecialtab page is directly using functions like "print" and "exit" to short-circuit our normal page controller.
Try asking your question on the new CiviCRM help site.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
November 08, 2014, 11:57:51 am
What about tabs whose content isn't generated by Civi -- eg rather by a Drupal, Joomla, WordPress?

Any idea how CiviHR is doing this now? When I look at the code, it still references snippet=1:

https://github.com/civicrm/civihr/blob/master/hrjob/hrjob.php#L193

but when navigating to a contact on the demo site (e.g. http://hrmaster.demo.civicrm.org/civicrm/contact/view?reset=1&cid=249 ), the AJAX request log looks a bit weird (attached).

If hook_civicrm_tabs requires pages to respond in a different format, then it should definitely be documented in http://wiki.civicrm.org/confluence/display/CRMDOC/API+changes

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
November 08, 2014, 12:03:11 pm
@totten that ajax output looks unrelated to loading tab content. CiviHR and other extensions would require no changes because they are not relying on the CMS to output tab content.

Here's a bit more explanation:
http://forum.civicrm.org/index.php/topic,34402.msg146385.html#msg146385
Try asking your question on the new CiviCRM help site.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
December 02, 2014, 05:22:27 am
Quote from: Coleman Watts on November 08, 2014, 10:05:42 am
`snippet=1` is deprecated

you mean to fetch data for the tabs only or is this globally deprecated?

eg. on civisualise for the dashlet, we use the same url as for the full page, but with snippet=1 Is this still the right approach?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
December 02, 2014, 05:54:48 am
Quote
you mean to fetch data for the tabs only or is this globally deprecated?

IMO it should be considered deprecated everywhere. I haven't come across a case for snippets 1-5 (excluding print, which is 2 I think) that couldn't be replaced by CRM.loadPage or CRM.loadForm (which automatically appends snippet=json to the url, you don't have to do it manually). So yes, if you are doing a manual call to jQuery.load (or similar) then you can simplify your code by replacing it all with the one-line CRM.loadPage.

However if you're talking about the CiviCRM dashboard on the homepage, that code has not been cleaned up yet and still uses some very old ajax techniques so I wouldn't try updating dashboard dashlets until that gets fixed up.
Try asking your question on the new CiviCRM help site.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?
December 02, 2014, 11:22:11 am
Quote from: Coleman Watts on December 02, 2014, 05:54:48 am
if you're talking about the CiviCRM dashboard on the homepage, that code has not been cleaned up yet and still uses some very old ajax techniques so I wouldn't try updating dashboard dashlets until that gets fixed up.

Yeap I'm talking about that place where souls go to die and hopes dry on the sand. Against my better judgement, I tried to integrate civisualize with it.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Changes to using hook _civicrm_tabs from 4.4.x to 4.5.3 ?

This forum was archived on 2017-11-26.