Low Events - show_passed="no" is not working correctly with entries tag. Need help.
I have a site that uses Low Events. It works very well other than I think I found a bug. This URL is showing events from the past when I visit:
http://domain.com/events/2012-08
I have my code setup as:
[code]
{exp:low_events:this_date
date="{segment_2}"
format="Upcoming Events"
year_format="%Y"
month_format="%F %Y"
week_format="Week %W"
day_format="%l %j %F %Y"
}
{exp:low_events:entries channel="calendar" show_passed="no" date="{segment_2}"}
{if no_results}
There are no entries available for the dates selected.
{/if} {title}
{calendar_dates:start_date format="%j %F %Y"}
{if calendar_dates:one_day == 'y'}
{calendar_dates:start_time format=", %h:%i %A"}
{if:else}
—
{calendar_dates:end_date format="%j %F %Y"}{calendar_dates:start_time format=", %h:%i %A"}
{/if}
{calendar_content}
{/exp:low_events:entries}
[/code]
The page that is displayed is still displaying ALL events from August 2012 and it is ignoring the show_passed="no" parameter. How can I fix this?
If I go to this URL it hides the past events as it should:
http://domain.com/events
It seems to not work when a YYYY-MM format is in the URL.
Replies
Low 7 Aug 2012 09:10
Hi Bryan,
Actually, this is intended behavior. When the given date is formated as YYYY-MM, a month unit is assumed, so all events for given month will be displayed. The show_passed="no" parameter will only work with unit "upcoming".
Reasoning behind this, is that if you're displaying events per month and you want to hide upcoming events, by the end of the month, nothing is displayed, which might look confusing for many people.
You can force the upcoming unit by adding unit="upcoming" to the entries tag. However, then you'd lose the dynamic behavior of the date param...
Bryan 7 Aug 2012 12:23
I tried this and the past events are still showing at the URL http://www.domain.org/events/2012-08
{exp:low_events:entries channel="calendar" unit="upcoming" show_passed="no" date="{segment_2}"}
The client wants me to HIDE the past events. Do I have the syntax wrong?
Bryan 7 Aug 2012 12:26
This does work perfect on the mini-calendar to hide past events:
{exp:low_events:calendar channel="calendar" start_day="sunday" show_passed="no" date="{segment_2}"}
I just can;t get it to work with Entries tag to hide the past events.
Low 7 Aug 2012 12:29
Ah yes, when the date '2012-08' is given, the working date for entries is set to the first of the month (so 2012-08-01), and passed events are determined by that date.
I admit that seems a bit counter intuitive, and I will look into changing this.
If your list is not a paginated list, you can also use the {if calendar_dates:passed != 'y'} conditional around an entry to hide the passed entries for now.
Bryan 7 Aug 2012 12:38
I removed the pagination and added the {if calendar_dates:passed != 'y'} and it works fine that way. I would probably fix that for a future release though as if the parameter is given to show_passed="no" it should hide them regardless I would think.
Thanks for your help and the work-a-round. :)
Bryan 7 Aug 2012 12:41
This is what works if anyone else is looking for this. This client only whows start dates but you can adjust that.
{exp:low_events:entries channel="calendar" show_passed="no" date="{segment_2}"}
{if no_results}
{if calendar_dates:passed != 'y'}
{calendar_dates:start_date format="%j %F %Y"}
{if calendar_dates:one_day == 'y'}
{calendar_dates:start_time format=", %h:%i %A"}
{if:else}
—
{calendar_dates:end_date format="%j %F %Y"}{calendar_dates:start_time format=", %h:%i %A"}
{/if}
{calendar_content}
{/if}
{/exp:low_events:entries}
Low 7 Aug 2012 12:42
Good to hear.
I'll add the show_passed for other units to the list of things to look at.
Bryan 7 Aug 2012 12:45
One last question. What I supply no date like this URL, http://www.domain.org/events/ that mini-calendar jumps to last month that an entry exists on. So if my last event is in October 2012, it jumps there rather than display current month. Why is that? Any way to stay on current month for initial page view?
here is my code:
{exp:low_events:calendar channel="calendar" start_day="sunday" show_passed="no" date="{segment_2}"}
←
{this_month format="%F %Y"}
→
{weekdays}{weekday_1}{/weekdays}
{weeks}
{days}
{if events_on_day}
{day_number}
{if:else}
{day_number}
{/if}
{/days}
{/weeks}
{/exp:low_events:calendar}
Bryan 7 Aug 2012 12:46
Here is code:
{exp:low_events:calendar channel="calendar" start_day="sunday" show_passed="no" date="{segment_2}"}
<table id="calendar">
<caption>
<a href="{path="events/{prev_month_url}"}" title="{prev_month format='%F %Y'}">←</a>
<a href="{path="events/{this_month_url}"}"><strong>{this_month format="%F %Y"}</strong></a>
<a href="{path="events/{next_month_url}"}" title="{next_month format='%F %Y'}">→</a>
</caption>
<thead>
<tr>
{weekdays}<th scope="col">{weekday_1}</th>{/weekdays}
</tr>
</thead>
<tbody>
{weeks}
<tr{if is_given_week} class="given-week"{/if}>
{days}
<td class="{if is_current}current{/if}{if is_given} given{/if}{if is_today} today{/if}">
{if events_on_day}
<a href="{path="events/{day_url}"}">{day_number}</a>
{if:else}
<span>{day_number}</span>
{/if}
</td>
{/days}
</tr>
{/weeks}
</tbody>
</table>
{/exp:low_events:calendar}
Low 7 Aug 2012 12:56
I take it the calendar tag comes after the entries tag, in your case?
Bryan 7 Aug 2012 13:02
That is correct. 2 column. The mini-calendar and entries are both using separate embeds.
<div class="rows">
<div class="rows-left">
{page_content}
{embed="includes/.calendar-list"} //entries listing
</div>
<div class="rows-right">
{embed="includes/.calendar"} // mini calendar
{embed="includes/.contact"}
</div>
</div>
Low 7 Aug 2012 13:04
That'll be a bug then. I've checked, and the other way around works as it should. Can reproduce it locally, so I'll get a bugfix ready as soon as I can.
Bryan 7 Aug 2012 13:12
Thank you so much. Low Events is a great additional to your solutions. It is super easy to use and works great. Please let me know when the fix is ready and I will test as I have a LIVE site using it.
Low 7 Aug 2012 13:15
Okay, quick fix that will be in the next version:
* Open up low_events/libraries/Low_date.php in a text editor
* Go to line #72, where you'll see these two lines:
* Move these lines to the first line of the init() method (around line #85), so it looks like this:
* Save, and you should be good to go.
Bryan 7 Aug 2012 13:25
Works perfect now! Thank you so much for the fast response.