ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

This Weeks Events Problem

June 15, 2011 11:06am

Subscribe [5]
  • #1 / Jun 15, 2011 11:06am

    Matt Harris

    95 posts

    Hi

    Having issues with showing “this weeks events”.

    Here’s the basic code I’m using.

    {exp:channel:entries channel="event" orderby="date" sort="asc" display_by="week" show_current_week="yes" start_day="Monday" show_future_entries="yes" status="open" limit="1" }
    
      <h2>{title}</h2><p> </p>
    
    <p> ... etc ...</p>
    
    <p><br />
      {if no_results}<br />
         Sorry no events this week, please view our calendar for up & coming events.<br />
      {/if}</p>
    
    <p><br />
    {/exp:channel:entries}


    It all works fine until there isn’t any events left for that week,
    at which point it displays the very last event in the channel.

    Any ideas why this happens ?

    Running EE v2.1.3 Build: 20110411

    Many Thanks.

  • #2 / Jun 16, 2011 6:40am

    John Henry Donovan

    12339 posts

    Matt,

    Can you trim some of those parameters to just this please?

    {exp:channel:entries channel="event" display_by="week" limit="1" show_future_entries="yes" show_current_week="yes" start_day="Monday"  status="open"}

    at which point it displays the very last event in the channel.

    Can you tell us more about this event. Is the date in the future? How far of the mark is the date for this event?

    Can you give us a few examples to work with or do you have a link to where this is happening?

  • #3 / Jun 16, 2011 10:32am

    Matt Harris

    95 posts

    Hi John

    I’ve updated the page with your trimmed code, it still has the same issues.

    I’m using placeholder data for the events, some are in the future and some have expiry dates set .

    I’ve sent you a PM with the links to the pages to have a look.
    The Calendar page will show you the dates for all events.

    Let me know if you want me to post my code for anything.

  • #4 / Jun 18, 2011 12:21pm

    Greg Salt

    3988 posts

    HI Matt,

    Can you please post the links you’ve mentioned or let us know some the basic entry data you’re using. As John Henry asked, how far away from the final display date is the rogue entry that is appearing?

    Cheers

    Greg

  • #5 / Jun 20, 2011 6:17am

    Matt Harris

    95 posts

    Hi Greg,
    Thanks, here are the links.

    This weeks events link:
    http://www.ticculture.co.uk/index.php/events/events_week/

    Full list of events in date order:
    http://www.ticculture.co.uk/index.php/events/events_list/

    Calendar page:
    http://www.ticculture.co.uk/index.php/events/calendar/


    Notes:

    (these are recent fieldtype additions)
    “EEvent Helper” (http://devot-ee.com/add-ons/eevent-helper/) to auto expire the events at the end of the day.

    “Time Select” (http://devot-ee.com/add-ons/time-select/) for the start and end time fields.

    All other fields are basic “title”, “Summary”, “Body” , “price” & “location” - textArea or textInput.

    I’ve removed all test data for this week, so it in the “broken” state where it’s displaying the last event (dated July 27th).

    If I add an event for this week then it’s displays them correctly.


    Let me know if you need any more info.

    Cheers

  • #6 / Jun 20, 2011 4:55pm

    Kevin Smith

    4784 posts

    Hey Matt,

    Based on the description of the display_by parameter, this appears to be expected behavior. It will only show one week, but if the current week doesn’t have any entries in it, then it will begin looking for entries in the weeks following. So given the parameters you’re using, unless there are no future entries, you’re not going to see the content wrapped by the {if no_results} conditional.

    Does that make sense?

  • #7 / Jun 21, 2011 5:47am

    Matt Harris

    95 posts

    Hey Guys,

    Kevin, thanks for the explanation, Anyone else find that an odd default behavior ?

    So what would be the best way to achieve a events Weeklist with a {if no_results_for_the_rest_of_the_week} fallback functionality ?

    Cheers

  • #8 / Jun 22, 2011 7:57am

    Sue Crocker

    26054 posts

    Hi, Matt.

    What I’d do is import a placeholder entry for each week, so you’d have at least one entry per week. That placeholder would be updated if there was real content, and left alone if it wasn’t. The placeholder could have the text of No event for this week or something similar.

    A bit more work, but I did something like that when prepping for a weekly quote a few years ago.

  • #9 / Jun 22, 2011 11:43am

    Matt Harris

    95 posts

    Hi Sue,

    It would be loads of work events happened all throughout the year.


    Think I’ve worked out a solution (not fully tested and requires php).

    Link to page…
    http://www.ticculture.co.uk/index.php/events/events_week/

    And code…

    {exp:channel:entries channel="event" show_future_entries="yes"  sort="asc" start_on="<?php echo date("Y-m-d", strtotime("last Monday")); ?> 00:00" stop_before="<?php echo date("Y-m-d", strtotime("next Sunday")); ?> 00:00"}
    
    ...
    
      {if no_results}
           
        no result for the week fallback content
                     
      {/if}
           
    {/exp:channel:entries}


    By using “start_on” and “stop_before” you can use {if no_results}.
    The php just echo’s in the dates for Monday and Sunday of the week you currently are in.

    I’m doing some testing now.

  • #10 / Jun 22, 2011 12:19pm

    Brandon Jones

    5500 posts

    Thanks Matt, let us know how it goes.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases