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) »
  • Put contact tabs into a block.
Pages: [1]

Author Topic: Put contact tabs into a block.  (Read 583 times)

aeszq

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 0
Put contact tabs into a block.
April 12, 2013, 12:26:46 am
Hi,

I'd like to put the contact tabs(summary, memberships, activities...) into a Drupal's block. Could you guys give me any advice of the right approach to take?

Thanks,
George 

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Put contact tabs into a block.
April 12, 2013, 06:25:21 am
Hey there,

You can use some jquery to do this.

If you have a URL that defines the content that you want to add (which is quite likely if it is a civicrm page) you can use something like

Code: [Select]
jQuery(document).ready(function(
    jQuery('#block_id').load('the_url);
});
If you are defining this block programmatically, your block view function would look something like this

Code: [Select]
function modulename_blockname_block(){
    drupal_add_js(drupal_get_path('module', modulename').'/js/yourfile.js');
    return '<p>The following div has some civicrm content in it</p><div id="block_id"></div>';
}

otherwise i guess you can allow js in your blocks input filter and just add it through the UI.  you might want to use CiviCRM's input filter for drupal for extra magic as well.

In terms of what URL to use...

http://drupal.demo.civicrm.org/civicrm/report/instance/1?force=1&snippet=1&section=2 is the results of report instance 1

and http://drupal.demo.civicrm.org/civicrm/contact/view/rel?reset=1&snippet=1&cid=10 is the relationships for the contact with id 10.

The snippet parameter is great for getting rid of all the extra stuff around the content that you are not interested in (that is normally useful to see all this since you want to see it in the page).

For reports the section parameter allows you to hide different sections like the report criteria which is quite handy.

An easy way to find the URL of the page that you want, especially if this is not visible in the URL (for example, when stuff gets loaded in a contact tab) is to open firebug or similar and look at the console which should display the URLs.

That should get your started!
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Put contact tabs into a block.
April 12, 2013, 06:26:49 am
ps. here is a real life example of doing some stuff like that: https://github.com/michaelmcandrew/ff/tree/master/drupal/sites/all/modules/custom/school_dashboard
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

aeszq

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 0
Re: Put contact tabs into a block.
April 14, 2013, 04:16:00 pm
Thanks, Michael. that's very helpful!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Put contact tabs into a block.

This forum was archived on 2017-11-26.