1

This is super weird. I have this channel entries loop:

{exp:channel:entries
  channel='resources_webinars'
  dynamic='no'
  limit='5'
  disable='categores|member_data|pagination'
  orderby='webinars_date'
  sort='asc'
  search:webinars_featured='=not_featured'
}
  {if webinars_date > current_time}

    {if count == 1}
      <div class="heading clearfix">
        <h3>Upcoming Webinars</h3>
      </div><!--/.heading-->

      <ul class="items webinars resetlist">
    {/if}

    <li class="clearfix">
      <article>
        <a href="{webinars_registration}" class="preview">
          <figure>
            {exp:ce_img:single 
              src='{webinars_thumb}' 
              width='210' 
              height='100' 
              crop='yes' 
              allow_scale_larger='yes' 
              alt='{title} preview'
            }
          </figure>
        </a>
        <div class="text clearfix">
          <header>
            <h4><a href="{webinars_registration}">{title}</a></h4>
            <p class="sml"><strong>{webinars_date format='%F %j, %Y'}</strong> / {webinars_date format='%g:%i%A'}</p>
          </header>
          <p>{webinars_summary}</p>
          <footer>
            <a href="{webinars_registration}" class="btn-ui action">Register</a>
          </footer>
        </div><!--/.text-->
      </article>
    </li>

    {if count == total_results}
      </ul>

      {if count == 5}
        <p class="learn-more clearfix"><a href="{path='resources/webinars/upcoming'}">View All Upcoming Webinars &raquo;</a></p>
      {/if}
    {/if}
  {/if}
{/exp:channel:entries}

It basically shows all non-featured upcoming webinars, sorted by a custom date field. What's weird is that adding sort="asc" causes the {if count} conditionals at the top and bottom not to work, so the opening and closing <ul> tags aren't output.

What's even weirder is that if I put sort="desc", everything works fine.

Anybody ever seen anything like this before?

EE 2.5.5

2 Answers 2

4

Count is an absolute entry count, so your earlier conditional of {if webinars_date > current_time} may be returning entries that the loop considers "1" but your conditional, run AFTER the returned counted entries, excludes it. In order to use count, you'd need to narrow the entries loop with a query or a parameter to exclude entries that you don't want returned, or move the {if count == "1"} conditional outside of that wrapping conditional so it fires no matter what.

5
  • An addon that may help you achieve the conditional as a parameter is Solspace's Date Field Filter, which allows you to essentially re-map what the entries loop uses as its date field, and therein you can specify a start date of today, using that newly re-mapped date field. Apr 17, 2013 at 17:59
  • Solspace's Date Field Filter is very tempting, but I'm using DropDate instead of EE's native date field, and I'd really prefer to keep it.
    – kmgdev
    Apr 17, 2013 at 18:31
  • I'm thinking Low Events might be a good solution, yeah?
    – kmgdev
    Apr 17, 2013 at 18:39
  • Date field filter may work on DropDate as well. It's really kind of like orderby="webinars_date" and then start_date="today". It doesn't take that form, but that's the idea. Apr 17, 2013 at 18:51
  • I haven't tried Low Events yet - depends on how sophisticated your event listing needs are. It's bound to be worth a look though. Everything he does is extremely well thought out. Apr 17, 2013 at 18:53
3

Are you sure it's not your {if webinars_date > current_time} conditional that is skipping entries?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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