1

I can't seem to figure out why the no_results tag isn't working for the Who's Attending page I'm working on. I have one page that lists all of the current events. You can click on any of the event titles to bring up a page that lists all attendees (entries with approved status). This is working very well but whenever you click on an event that doesn't contain entries with an approved status the no_results tag doesn't work. Below is the code I'm using:

 <p>You have selected <strong>{last_segment}</strong></p><hr/>
 <p>Please find below the list of attendees for this event:</p><br>
  <ul>
   {exp:channel:entries channel="event_registration" status="Approved"
    limit="300" search:event="{last_segment}"}
   <li>{registrant}</li>
   {if no_results}<p>No one has registered for this event yet.</p>{/if}
   {/exp:channel:entries}
  </ul>

I have tried the adding 'require_entry="yes"', adding dynamic="yes" and dynamic="no" to no avail. I've also tried using the three methods below:

{if total_results == "0"}No one has registered for this event yet.{/if}
{if count < 1}<p>No one has registered for this event yet.</p>{/if}
{if count == 0}<p>No one has registered for this event yet.</p>{/if}

I'm still unable to get the no results message to display. It should also be noted that if I add a {count} tag to my template it will output the total number of entries if there is at least one entry. The {count} tag doesn't output 0 or anything at all if there aren't any entries. Any tips or suggestions for getting this working would be greatly appreciated, Thanks!

3
  • 1
    If you put some text inside the {exp:channel:entries} query, does it output anything at all? It sounds to me like that query isn't actually doing anything, so any code you have inside it (including the if no_results statement) isn't even executing? If you put <p>Test</p> inside the query, does it output that to your browser? I'm also pretty sure dynamic will need to be set to yes because you're basing the query on a dynamic URL . – Andy Nov 16 '16 at 16:38
  • Thank you Andy for the reply. I just added <p>test</p> under the list item with the custom field {registrant} in it. Now it outputs 'test' when there are results and nothing at all when there aren't results. It doesn't seem to even parse the no_results tag. I added dynamic="yes" back into it but still no change. At least the main part is working and showing entries. I might have to settle for adding a generic message below that states if the above list is blank then there are no results but I'd hate to do that. If you have any other suggestions to try please let me know. Thanks again! – Andrew Currie Nov 16 '16 at 18:17
  • I just got it working! Turns out it was the result of having the member custom profile data tag, {exp:member:custom_profile_data}, around my channel entries tags. Once I removed that the no results message started working. I hadn't included this part of the template in my code sample above so you had no way of knowing I was using these tags. I've given you an up vote for your help. So happy it's working now. Thanks! – Andrew Currie Nov 16 '16 at 18:31
2

Removing the custom profile data tag around my channel entries tag resolved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.