CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Getting membership information for summary.tpl template
Pages: [1]

Author Topic: Getting membership information for summary.tpl template  (Read 638 times)

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Getting membership information for summary.tpl template
August 04, 2011, 10:20:26 am
I'm trying to do something which should be quite simple: I want to display basic membership information on the contact summary page by adjusting the summary.tpl custom template.

I had this working a month or so ago with a little bit of Smarty code under API v3, but recently it has stopped working.   :'(

My code is:

<tr>
  <td class="label">Memberships</td>
  <td id="memberships">
{crmAPI var="MembershipS" entity="Membership" action="get" version="3" contact_id=$contactId }
{foreach from=$MembershipS.values.$contactId item=Membership}
{if $Membership.status_id eq "2" or $Membership.status_id eq "3"}
 {$Membership.membership_name} membership ending
 {$Membership.membership_end_date}
{/if}
{/foreach}
</td>
</tr>


Any ideas why this has stopped working?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Getting membership information for summary.tpl template
August 05, 2011, 04:49:35 am
Below code is working fine

Quote
{crmAPI var="MembershipS" entity="Membership" action="get" version="3" contact_id=$contactId }
{foreach from=$MembershipS.values item=Membership}
   {if $Membership.status_id eq "2" or $Membership.status_id eq "3"}
       {$Membership.membership_name} membership ending {$Membership.membership_end_date|crmDate}
  {/if}
{/foreach}

HTh
Kurund
Found this reply helpful? Support CiviCRM

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: Getting membership information for summary.tpl template
August 05, 2011, 06:08:46 am
Kurund, thanks so much for that. It works now. Maybe the structure of the data returned by the API changed and I didn't notice.

I also like the |crmDate thing that you added on - the format is much more user friendly.  ;D

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Getting membership information for summary.tpl template

This forum was archived on 2017-11-26.