0

My event php page prints all events saved. I would like to change this and only print events starting later than the current date.

I suppose I need to get the current date and compare the date in my event with the current date.

My code looks like this so far:

<?php
$filters = NULL;
$order = array('date' => 'desc');

$eventNodes = get_nodes('event', LANGUAGE, $filters, $order);
foreach ($eventNodes as $eventNode) :
?>

<li>
    <a href="<?php print_full_path('url', FALSE, $eventNode); ?>">
        <div class="photo">
            <div class="inner"></div>
            <img src="images/partner_placeholder.gif" class="placeholder" alt="" />
            <img alt="" src="uploads/<?php print_node_field('overview-image', FALSE, 0, $eventNode); ?>" class="img">
        </div>
        <h4><?php print_node_field('title', FALSE, 0, $eventNode, 60); ?></h4>
        <h5 style="margin: -8px 0 0px;">
        <?php
        $date = print_node_field('date', TRUE, 0, $eventNode);
        if (!empty($date)) {
            print date('d/m/Y', strtotime($date));
        }
        ?>
        <?php
        $date = print_node_field('date-until', TRUE, 0, $eventNode);
        if (!empty($date)) {
            print " - " . date('d/m/Y', strtotime($date));
        }
        ?>
        </h5>
        <p><?php print_node_field('location', FALSE, 0, $eventNode); ?></p>
        <span class="btn">Read more</span>
    </a>
</li>

<?php endforeach; ?>

Any ideas on how to do this in a simple way using the foreach loop?

Thanks in advance!

David Jones
  • 4,275
  • 6
  • 27
  • 51
pedroargenti
  • 3
  • 1
  • 5
  • Possible duplicate: http://stackoverflow.com/questions/2113940/php-compare-date – allejo Nov 04 '14 at 16:26
  • The base of your problem is that you need to adjust the retrieving of data from your saved events. For instance in MySQL you will have to edit the query to return the events from the current date or higher. It's too troublesome to start editing a full array of data to match what you want. – Rimble Nov 04 '14 at 16:29

0 Answers0