CRM-13438 - detect / render subtype templates
authorDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Wed, 25 Sep 2013 12:11:26 +0000 (17:41 +0530)
committerDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Wed, 25 Sep 2013 12:11:26 +0000 (17:41 +0530)
CRM/Contact/Page/View.php
CRM/Contact/Page/View/Summary.php

index ed59b55b7317572ae65f6e0a8e7b419490791f84..41bcb0dfc508a3d449dbc8bee26a6cb5e0a73207 100644 (file)
@@ -192,7 +192,9 @@ class CRM_Contact_Page_View extends CRM_Core_Page {
     $this->assign('displayName', $displayName);
 
     $this->set('contactType', $contactType);
-    $this->set('contactSubtype', $contactSubtype);
+
+    // note: there could still be multiple subtypes. We just trimming the outer separator.
+    $this->set('contactSubtype', trim($contactSubtype, CRM_Core_DAO::VALUE_SEPARATOR));
 
     // add to recently viewed block
     $isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
index 92fc54b6ee79918807d68637918fa12c452ea6c2..c09ffc481041e5e548f30178bf754173ac954eeb 100644 (file)
@@ -392,12 +392,17 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
 
   function getTemplateFileName() {
     if ($this->_contactId) {
-      $csType = $this->get('contactSubtype');
-      if ($csType) {
-        $templateFile = "CRM/Contact/Page/View/SubType/{$csType}.tpl";
-        $template = CRM_Core_Page::getTemplate();
-        if ($template->template_exists($templateFile)) {
-          return $templateFile;
+      $contactSubtypes = $this->get('contactSubtype') ? 
+        explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->get('contactSubtype')) : array();
+
+      // there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
+      foreach ($contactSubtypes as $csType) {
+        if ($csType) {
+          $templateFile = "CRM/Contact/Page/View/SubType/{$csType}.tpl";
+          $template = CRM_Core_Page::getTemplate();
+          if ($template->template_exists($templateFile)) {
+            return $templateFile;
+          }
         }
       }
     }