Answers.Body: <p>Watch out: role_id=&quot;X&quot; &gt; adjust to your needs.
  Tested and working.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-18T10:55:29.343Z
Answers.LastActivityDate: 2021-02-18T10:55:29.343Z
Answers.UserDisplayName: Guitarman
Body: <p>If you want to display the number of remaining event participants (based on their <strong>role</strong>, too) until an event is fully booked, you could implement the following in EventInfo.tpl:</p>
  <pre><code>&lt;div class=&quot;crm-section event_remaining&quot;&gt;
      &lt;div class=&quot;label&quot;&gt;Participants&lt;/div&gt;
          &lt;div class=&quot;content&quot;&gt;{crmAPI var=&quot;ParticipantS&quot; entity=&quot;Participant&quot; action=&quot;get&quot; role_id=&quot;1&quot; sequential=&quot;1&quot; event_id=$event.id }
      {if $event.max_participants&lt;=$ParticipantS.count}
          0&amp;nbsp;remaining
      {else}
      {math equation=&quot;x - y&quot; x=$event.max_participants y=$ParticipantS.count}&amp;nbsp;remaining
      {/if}
           &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-18T11:30:01.383Z
Comments.Text: Hi Guitarman: I'm sure that's very useful, but that isn't a question (and your answer is a comment). You can provide your own answers, but you should phrase a question and then provide an answer to it. Keeping to the convention makes it easier to use.
Comments.UserDisplayName: Mick Kahn
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-18T14:00:39.957Z
Comments.Text: You're right, I rephrased this.
Comments.UserDisplayName: Guitarman
Tags: <civievent><participants>
Title: How to display remaining event participants?
ThreadText: # How to display remaining event participants?
  
  (Asked by: username_0 on 2021-02-18)
  
  If you want to display the number of remaining event participants (based on their **role**, too) until an event is fully booked, you could implement the following in EventInfo.tpl:
  
  ```
  <div class="crm-section event_remaining">
      <div class="label">Participants</div>
          <div class="content">{crmAPI var="ParticipantS" entity="Participant" action="get" role_id="1" sequential="1" event_id=$event.id }
      {if $event.max_participants<=$ParticipantS.count}
          0&nbsp;remaining
      {else}
      {math equation="x - y" x=$event.max_participants y=$ParticipantS.count}&nbsp;remaining
      {/if}
           </div>
  </div>
  
  ```
  
  **Tags:** civievent, participants
  
  > **Comments:**
  > **username_1**: Hi username_0: I'm sure that's very useful, but that isn't a question (and your answer is a comment). You can provide your own answers, but you should phrase a question and then provide an answer to it. Keeping to the convention makes it easier to use.  
  > **username_0**: You're right, I rephrased this.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-02-18. Score: 0 | Accepted answer
  
  Watch out: role\_id="X" > adjust to your needs.
  Tested and working.
  
  
  ---
  
  