From: Deepak Srivastava Date: Wed, 25 Sep 2013 12:11:26 +0000 (+0530) Subject: CRM-13438 - detect / render subtype templates X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ae34b946f22ebdfdef423aa60cada6c7bc742ab8;p=civicrm-core.git CRM-13438 - detect / render subtype templates --- diff --git a/CRM/Contact/Page/View.php b/CRM/Contact/Page/View.php index ed59b55b73..41bcb0dfc5 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -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'); diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 92fc54b6ee..c09ffc4810 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -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; + } } } }