Answers.Body: <p>(adding as an answer - see comment thread above)</p>
  
  <p>In the DB, contact_sub_type uses a special character to split multiple contact types. If this is being carried through to smarty then 'eq' might not produce a match (but the non-HTML character wouldn't be printed to screen). Can smarty check whether the $contactSubType just contains 'Society'?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-09T16:44:20.370Z
Answers.LastActivityDate: 2016-02-09T16:44:20.370Z
Answers.UserDisplayName: Andrew West
Answers.Body: <p>If isset contact ID ($contactId), you can use API in smarty like this:</p>
  
  <pre><code>        {crmAPI var='result' entity='Contact' action='get' id=$contactId}
          {foreach from=$result.values item=contact}
              &lt;div&gt;$contact.contact_type&lt;/div&gt;
              {if $contact.contact_type eq 'Organization'}
                  {* ... html ....*}
              {/if}
          {/foreach}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-22T15:59:09.397Z
Answers.LastActivityDate: 2017-05-23T20:41:20.380Z
Answers.LastEditDate: 2017-05-23T20:41:20.380Z
Answers.UserDisplayName: Sirius
Answers.Body: <p>If you want to hide Contact Details, the best way is explained in this post:
  <a href="https://civicrm.stackexchange.com/questions/9349/how-do-i-edit-activity-forms/9350?noredirect=1#comment9167_9350">How do I edit activity forms?</a></p>
  
  <p>In my opinion the best way is to create a little extension and add a template with some jQuery code to hide the Contact Details. But you could give the css way a go too?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-09T10:10:23.533Z
Answers.Text: Thank you for valuable input, however, it doesn't answer the initial question, which is "why contact subtype check fails in smarty template, where contact type check works". Besides, as it was stated, elements should be hidden depending on contact subtype, which returns us to a starting point again..
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-09T08:28:22.193Z
Answers.LastActivityDate: 2016-02-09T08:28:22.193Z
Answers.LastEditDate: 2017-04-13T12:53:13.167Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>Have  strange issue checking contact type in <strong>\templates\CRM\Contact\Form\Contact.tpl</strong></p>
  
  <p>This code prints  <strong>Organization / Society</strong></p>
  
  <pre><code>{$contactType} / {$contactSubType} 
  </code></pre>
  
  <p>This code prints <strong>Organization / Society</strong> </p>
  
  <pre><code>{if $contactType eq 'Organization'}
     {$contactType} / {$contactSubType}
  {/if}
  </code></pre>
  
  <p>But this one prints nothing</p>
  
  <pre><code>{if $contactSubType eq 'Society'}
         {$contactType} / {$contactSubType}
  {/if}
  </code></pre>
  
  <p>And this one prints nothing</p>
  
  <pre><code>{if $contactType eq 'Organization' &amp;&amp; $contactSubType eq 'Society'}
         {$contactType} / {$contactSubType}
  {/if}
  </code></pre>
  
  <p>Shouldn't it "just" work? Or it's another bit of CiciCRM magic?  </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-09T08:26:07.717Z
Comments.Text: What are you trying to achieve? It might well be that modifying a template is not the best route to whatever you are trying to do (and it hardly ever is).
Comments.UserDisplayName: ErikH - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-09T11:53:15.473Z
Comments.Text: In the DB contact_sub_type uses a special character to split multiple contact types. If this is being carried through to smarty then 'eq' might not produce a match (but the non-HTML character wouldn't be printed to screen). Can smarty check whether the $contactSubType just contains 'Society'?
Comments.UserDisplayName: Andrew West
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-09T12:40:26.143Z
Comments.Text: @AndrewWest : That's probably it, thanks a million for useful cue! Hope Smarty has  kind of "eliminate special characters"  built-in. Wish I could mark your comment as an answer.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-09T13:09:47.793Z
Comments.Text: no probs! report back if that fixes it and I can add it as a proper answer.
Comments.UserDisplayName: Andrew West
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-09T15:21:59.360Z
Comments.Text: @AndrewWest : it definitely works after eliminating of U+001 special char added at the beginning at the end of contact sub-type name, thanks again for proper answer!
Comments.UserDisplayName: yurg
Tags: <contacts><smarty>
Title: Contact SubType check fail in Smarty TPL file
ThreadText: # Contact SubType check fail in Smarty TPL file
  
  (Asked by: username_0 on 2016-02-08)
  
  Have strange issue checking contact type in **\templates\CRM\Contact\Form\Contact.tpl**
  
  This code prints **Organization / Society**
  
  ```
  {$contactType} / {$contactSubType} 
  
  ```
  
  This code prints **Organization / Society**
  
  ```
  {if $contactType eq 'Organization'}
     {$contactType} / {$contactSubType}
  {/if}
  
  ```
  
  But this one prints nothing
  
  ```
  {if $contactSubType eq 'Society'}
         {$contactType} / {$contactSubType}
  {/if}
  
  ```
  
  And this one prints nothing
  
  ```
  {if $contactType eq 'Organization' && $contactSubType eq 'Society'}
         {$contactType} / {$contactSubType}
  {/if}
  
  ```
  
  Shouldn't it "just" work? Or it's another bit of CiciCRM magic?
  
  **Tags:** contacts, smarty
  
  > **Comments:**
  > **username_1**: What are you trying to achieve? It might well be that modifying a template is not the best route to whatever you are trying to do (and it hardly ever is).  
  > **username_2**: In the DB contact_sub_type uses a special character to split multiple contact types. If this is being carried through to smarty then 'eq' might not produce a match (but the non-HTML character wouldn't be printed to screen). Can smarty check whether the $contactSubType just contains 'Society'?  
  > **username_0**: @username_2 : That's probably it, thanks a million for useful cue! Hope Smarty has  kind of "eliminate special characters"  built-in. Wish I could mark your comment as an answer.  
  > **username_2**: no probs! report back if that fixes it and I can add it as a proper answer.  
  > **username_0**: @username_2 : it definitely works after eliminating of U+001 special char added at the beginning at the end of contact sub-type name, thanks again for proper answer!  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2016-02-09. Score: 2 | Accepted answer
  
  (adding as an answer - see comment thread above)
  
  In the DB, contact\_sub\_type uses a special character to split multiple contact types. If this is being carried through to smarty then 'eq' might not produce a match (but the non-HTML character wouldn't be printed to screen). Can smarty check whether the $contactSubType just contains 'Society'?
  
  
  ---
  
  ### Answer by username_3 on 2017-05-22. Score: 1
  
  If isset contact ID ($contactId), you can use API in smarty like this:
  
  ```
          {crmAPI var='result' entity='Contact' action='get' id=$contactId}
          {foreach from=$result.values item=contact}
              <div>$contact.contact_type</div>
              {if $contact.contact_type eq 'Organization'}
                  {* ... html ....*}
              {/if}
          {/foreach}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2016-02-09. Score: -1
  
  If you want to hide Contact Details, the best way is explained in this post:
  [How do I edit activity forms?](https://civicrm.stackexchange.com/questions/9349/how-do-i-edit-activity-forms/9350?noredirect=1#comment9167_9350)
  
  In my opinion the best way is to create a little extension and add a template with some jQuery code to hide the Contact Details. But you could give the css way a go too?
  
  > **Comments:**
  > **username_0**: Thank you for valuable input, however, it doesn't answer the initial question, which is "why contact subtype check fails in smarty template, where contact type check works". Besides, as it was stated, elements should be hidden depending on contact subtype, which returns us to a starting point again..  
  
  ---
  
  