All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Having trouble creating a month-specific Events archive template

Rick 4 Oct 2012 12:43 problem, complete

Hi;

I have my events page set up and working fine, and in the sidebar I have a list of monthly ‘archive’ links (November 2012, December, 2012, etc). The hrefs for these links resolve to (for example) www.example.com/index.php/events/arch...

I already have archive pages set up for regular channel entries (like Blog, Discussions, etc) but clearly the differences between regular channel entries and low_events entries are throwing me off because I can't get the events/archive template to respond dynamically to the date in the URL. Specifically:

1. The page’s H1 heading that should automatically display the month specified in the URL seems to display the month of the earliest Event (not sure if it's displaying the event's start date or the date that event entry was posted).

2. The low_events:entries loop is showing all upcoming events, not limiting the list to those in the intended month.

My template code is essentially just a tweaked version of the one that I used for my standard channel archives (it works as expected in that context) so clearly there is something that I'm not getting about how Low Events works, how the template syntax differs from normal channel syntax, and how it handles dates. Any help would be much appreciated. Here's some extra information:

The template code is as follows:

 
<!-- Page heading, should pick up month from URL and display it -->
{exp:low_events:entries channel="events" limit="1" date="{segment_3}"}
{date_heading display="monthly"}
<h1>{channel} <span>Posts from {entry_date format="%F, %Y"}</span></h1>
{/date_heading}
{/exp:low_events:entries}

{!-- List events taking place this month --}
<h2>Events This Month</h2>
{exp:low_events:entries channel="events" disable="categories|member_data|pagination"}
{if no_results}
<p class="no-results ">No events listed.</p>
{/if}
<h3>{title}</h3>
<p class="date"><strong>{events_datetime:start_date format="{snp_event_date_format}"}</strong></p>
<br>
{/exp:low_events:entries}


The links that take the visitor to the events archive page are generated as follows:
 
{exp:low_events:archive channel="events" disable="categories|member_data|pagination" limit="5" show_passed="no"}
<li><a href="{path='events/archive/{date_url}'}">{month} {year}</a></li>
{/exp:low_events:archive}


The URL that these links generate is as described at the start of this post.

Many thanks in advance.
Rick

Replies

  1. Low 4 Oct 2012 12:59

    Hi Rick,

    The main thing to remember here, is that all native date header/footer variable pairs use the entry_date, not the Low Events custom field, for their calculations. Don't use any of the {date_heading} or {entry_date} variables if they apply to the event dates.

    Also important: the low_events:entries tag will show events based on the date="" and unit="" parameters. Here's a set of rules:
    * if no date="" is given, today is assumed
    * if no unit="" is given, upcoming is assumed, unless a date="" is given
    * if a date="YYYY" is given, but no unit="", a unit="year" is assumed
    * if a date="YYYY-MM" is given, but no unit="", a unit="month" is assumed
    * if a date="YYYY-MM-DD" is given, but no unit="", a unit="day" is assumed
    * Explicitly setting the unit="" will override the assumption made by the date="" param

    Right, so you want to show a list of entries based on the month in the URI. This means you have to pass that on to the tag:

    {exp:low_events:entries channel="events" date="{segment_3}"} 
    {if count == 1}
    {channel} Posts from
    {exp:low_events:this_date date="{segment_3}" format="..."}
    {/if}

    {title}
    {other_custom_fields}
    {/exp:low_events:entries}


    Here you'll see that the header is inside the main low_events:entries loop. You can use the low_events:this_date tag to format the month in the URI.

    Does that help?

  2. Rick 4 Oct 2012 13:45

    Thanks very much for the speedy reply, Low. I'm going to try and get my head around those changes and see how they play out in my template. In the meantime, here's a follow-up question:

    In my regular Events listing page (which is working) the date variable inside my low_events:entries loop is specified as {events_datetime:start_date format="{...whatever...}"} I must have culled that events_datetime syntax from some part of the documentation but I cannot now find any reference to it, and every date field mentioned in the documentation has the syntax {events_date:xxxx format="{...whatever...}"} However, if I change my code from events_datetime to events_date my template no longer works.

    Where on earth did I find that events_datetime reference, and why does it work when events_date does not?

  3. Low 4 Oct 2012 13:48

    That would be the custom field name. When you create a Low Events custom field, you give it a name. For example: events_date or event_details or foo_bar. Use that name as the first part in your Entries tag, so:

    {events_date:xxx} 
    or
    {event_details:xxx}
    or
    {foo_bar:xxx}

  4. Rick 4 Oct 2012 14:03

    Oh christ, you're right! It's the name that I gave it! D’oh!

    I can see how I confused myself though; my standard policy of starting the name of each custom field with the name of the field group (ie. groupname_fieldname) came back to bite me here, because it matched your syntax a bit too closely.
    Maybe I just need some sleep...

    Thanks for the reply though. *slinks away in shame*

  5. Low 5 Oct 2012 06:53

    How's the original issue? Still need help with that?

  6. Rick 5 Oct 2012 17:11

    Hi Low, sorry for the slow response – been head-down in VAT bookkeeping all day. Thanks for checking back with me. But no, I think I got it all sorted, thanks to your code earlier in the thread. I'm still not convinced that I've got my head around the way that low_events works and how it differs from regular channel entries -- which does rather suggest that I'll be back here sooner or later to get my thinking straightened out again. But for now I'm good, thanks.