6

Specifically -> I'd like to see what's in the Membership Tab -> Inline instead. I'd like that table with Active Memberships printed right at the top underneath the Display Name on civicrm/contact/view?reset=1&cid=xxx

When you add a Custom Data Set/Field you get a choice between Tab and Inline. Which is very cool. But how to go about switching a Core Tab -> Inline?

It's not as simple as finding the tpl - and then injecting that into the CRM/Contact/Page/View/Summary.tpl - as the $ variables aren't known. I don't really want to be copying phps bit over - I think?

5

Rather than smarty, JavaScript will do the trick. Those tabs are all separate pages, and you can load any CiviCRM page/form as a snippet instead.

First, in your extension, use a hook to include the Javascript and provide the contact ID for it:

$r = CRM_Core_Resources::singleton()

// Provide the contact ID (assuming you've got it handy)
$r->addVars('memberTabInline', array('contactId' => $contactId));

// Add the script
$r->addScriptFile('com.example.membertabinline', 'membertabinline.js')

Then in membertabinline.js:

CRM.$(function($) {
  $.get(CRM.url('civicrm/contact/view/membership', {
    reset: 1,
    force: 1,
    cid: CRM.vars.memberTabInline.contactId,
    snippet: 1
  }), function(result) {
    $('#mainTabContainer').append(result);
  });
});

You'll probably need to add a div or something and have this fill it so that you don't have the membership stuff appending multiple times, but this is the gist.

Alternatively, you might look at https://wiki.civicrm.org/confluence/display/CRMDOC/Ajax+Pages+and+Forms to see if you can fill a wrapper with the tab and have it work. I'm only familiar with this re: popups, but it looks like it might work within any element.

  • Cool - thanks for this - will try this out! – KarinG - Semper IT Jul 21 '16 at 22:32
  • I just tried this out and this works great - the entire - and I mean the entire - content of the Membership tab is now position (with .prepend(result) on my contact view page for my contactId. Learned something. Merci Andrew! – KarinG - Semper IT Jul 22 '16 at 4:07
  • CiviCRM never ceases to amaze me ... was looking for answer on an unrelated topic and stumbled on this, thanks Karin and Andrew for this Q&A! – Nicolas at cividesk Sep 29 '17 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.