I'm working on a hook to display a users PCPs on a custom contact tab. We use PCPs extensively and it would be great to see any pages the contact owns inside their contact card. (Rather than having to pull up the full list of PCPs in a separate window. I also know that there's a link to PCPs in the soft credit section of the contribution tab - but that's only if there is a contribution to the page.)
I'm able to make a custom tab (using the tabset hook) but am struggling how to actually get content on to the tab.
// let's add a new "contribution" tab with a different name and put it last // this is just a demo, in the real world, you would create a url which would // return an html snippet etc. $url = CRM_Utils_System::url( 'civicrm/contact/view/contribution', "reset=1&snippet=1&force=1&cid=$contactID" ); // $url should return in 4.4 and prior an HTML snippet e.g. '<div><p>....'; // in 4.5 and higher this needs to be encoded in json. E.g. json_encode(array('content' => <html form snippet as previously provided>)); // or CRM_Core_Page_AJAX::returnJsonResponse($content) where $content is the html code // in the first cases you need to echo the return and then exit, if you use CRM_Core_Page method you do not need to worry about this. $tabs = array( 'id' => 'mySupercoolTab', 'url' => $url, 'title' => 'Contribution Tab Renamed', 'weight' => 300 );
But I don't know what to set my own url to AND get content on it. I'm in Wordpress 4.3.1 and Civi 4.6.4. Suggestions?