Jump to content

tourdates / shows


rolspace.net
 Share

Recommended Posts

Hi everyone

I'm kinda new here and have a little problem. I'm working on a website for a band and I want to show Future and Past Tourdates (Shows). Now I managed to get the Dates to show up correctly but wonder how I could do the split between Future and Past shows. Here's my code so far:

<table>
          <tr>
            <th>Date</th>
            <th>Venue</th>
            <th>City</th>
            <th>Ticket</th>
          </tr>
        <?php foreach ($pages->get('/shows/')->children as $show) { ?>
          <tr>
            <td><?php echo $show->show_date;  ?></td>
            <td><?php echo $show->title; ?></td>
            <td><?php echo $show->show_venue; ?></td>
              <td><a href="<?php echo $show->show_ticket_url; ?>" target="_blank">get tickets</a> </td>
          </tr>
       <?php } ?>
       </table>

Any quick solutions to this?

Thanks

Edited by LostKobrakai
added codeblock
Link to comment
Share on other sites

<?php

    $threshold = strtotime(date('d.m.Y 00:00:00'));  // = today
    
    $selectorFuture = "parent=/shows/, show_date>={$threshold}, sort=show_date";  // or: sort=-show_date
    $selectorPast   = "parent=/shows/, show_date<{$threshold}, sort=show_date";  // or: sort=-show_date

    foreach($pages->find($selectorFuture) as $show) {
        // echo table rows here
        ...
    }
    foreach($pages->find($selectorPast) as $show) {
        // echo table rows here
        ...
    }

 

  • Like 3
Link to comment
Share on other sites

My code example is a bit lengthy. I copied it from an event template with another usecase. There we have a start_date and optionaly an end_date too. Only all future events and or currently active events should be shown on the site, also those where the start_date is in the past, but the end_date is in the future:

$threshold = strtotime(date('d.m.Y 00:00:00'));
$selector1 = "template=ptlist-events, event_disabled=0, event_date_start>={$threshold}, sort=event_date_start";
$selector2 = "template=ptlist-events, event_disabled=0, event_date_end>={$threshold}";

$events = $pages->find($selector1);      // find all events that start today or in the future
$events->add($pages->find($selector2));  // find all events that end in the future, even if they started in the past, 
                                         // and add to PageArray
$events->sort('event_date_start');
foreach($events as $k => $v) {
    printEvent($v);
}

PageArray stores by ID, so there are no duplicate entries in the final PageArray.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...