Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-1065

Simple Hook To Allow Adding Arbitrary Links Into the Contact Summary (Basic.tpl) Template

    Details

    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Labels:
      None

      Description

      We needed to add some additional UI to the contact summary page for a customer. Rather than simply hack it into Basic.tpl, I've implemented a simple callback hook that lets any module add links to the line above the activity links that now appear.

      Here's the signature of the hook:

      /**

      • Rob's hook for getting into the basic template
        *
      • @param string $op
      • @param int $contact_id
        *
      • @return array
        */
        function hook_civicrm_links($op, $contact_id) { $links = array(); $links[] = array('icon' => url('misc/favicon.ico'), 'title' => t('Drupalify Contact'), 'href' => url("civinode/contact/$contact_id") ); return $links; }

      This is dead easy to implement for the end users, and makes it possible for us to do things like "Create a Drupal account for this user", or "purchase a gift for this user via the ecommerce module".

      I've implemented the hook, modified the Basic view template, and a small Smarty template that draws the icons in the same style as ActivityLinks.tpl. A new CRM_Utils_Hook::links does the work (implemented for Drupal, stubbed for Mambo and SOAP).

      // let the user frameworks add some links to the page
      $uf_links = CRM_Utils_Hook::links( 'view', $this->_contactId );
      if ( $uf_links )

      { $defaults['hook_civicrm_links'] = $uf_links; }

      It would make a few of us pretty happy if this or something like it gets into 1.5.

      Thanks,
      Rob

        Attachments

          Activity

            People

            • Assignee:
              abhilasha Abhilasha Vasu
              Reporter:
              torenware Rob Thorne
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: