Render the CiviMember component on the dashboard.
authorDavid Thompson <davet@gnu.org>
Tue, 30 Sep 2014 20:04:07 +0000 (16:04 -0400)
committerDavid Thompson <davet@gnu.org>
Tue, 30 Sep 2014 20:04:07 +0000 (16:04 -0400)
* CRM/Memberdashboard/Page/MemberDashboard.php (buildDashboard): New
  method.
* templates/CRM/Memberdashboard/Page/MemberDashboard.tpl: Render component.

CRM/Memberdashboard/Page/MemberDashboard.php
templates/CRM/Memberdashboard/Page/MemberDashboard.tpl

index 3cc8669e8509e5d47416501f5a8d6aea7cb3d81a..f25a94ece224f548a7b9ffbdd375e813fe56ce3a 100644 (file)
@@ -18,11 +18,30 @@ class CRM_Memberdashboard_Page_MemberDashboard extends CRM_Core_Page {
     $this->contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults);
   }
 
+  function buildDashboard() {
+    $components = CRM_Core_Component::getEnabledComponents();
+
+    // Use the CiviMember component dashboard.
+    $memberComponent = $components['CiviMember'];
+    $elem = $memberComponent->getUserDashboardElement();
+    $userDashboard = $memberComponent->getUserDashboardObject();
+    $userDashboard->run();
+    $dashboardElement = array(
+      'class' => 'crm-dashboard-' . strtolower($memberComponent->name),
+      'sectionTitle' => $elem['title'],
+      'templatePath' => $userDashboard->getTemplateFileName(),
+      'weight' => $elem['weight'],
+    );
+    $this->assign('element', $dashboardElement);
+  }
+
   function run() {
     CRM_Utils_System::setTitle(ts('Welcome, ') . $this->contact->first_name . '!');
 
     $this->assign('contact', $this->contact);
 
+    $this->buildDashboard();
+
     parent::run();
   }
 }
index c3d4651d51399a6b320a7eb1e26635a9e218edaf..8d51908055d9f1fccf5d992e04338d4a2eb049ad 100644 (file)
@@ -2,3 +2,10 @@
 
 <p>Your display name is {$contact->display_name}</p>
 <p>Your contact ID is #{$contact->id}</p>
+
+<tr{if isset($element.class)} class="{$element.class}"{/if}>
+  <td>
+    <div class="header-dark">{$element.sectionTitle}</div>
+    {include file=$element.templatePath}
+  </td>
+</tr>