I would like to have a view with a bunch of node types, but one of those types is events and I don't want past events in the view so the Start Date is filtered by 'now'. Unfortunately none of the other node types have a start data at all so they are filtered out.

Any ideas how to get around this and include those non-events in the view?

Thanks.

Comments

MattClare’s picture

Component: User interface » Code

DISCLAIMER: I don't know what I'm doing!

Here's a stop-gap that I cobbled together and added to the cron.php:

//Add a start date to stories to help with mixed event/story views

$sql = "SELECT `nid`,`type`,`sticky`,`created`  FROM `node` WHERE `type` = 'story'";
$result = db_query($sql);
while ($obj = db_fetch_object($result)) {
    if ($obj->sticky == 1) { //if sticky
        $tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
        $sql = "INSERT INTO `event` (`nid`, `event_start`, `event_end`, `timezone`) VALUES ('".$obj->nid."', '".$tomorrow."' , '".$tomorrow."', '308');";
        $result2 = db_query($sql);
        if (db_error()) {
        	$sql = "INSERT INTO `event` (`nid`, `event_start`, `event_end`, `timezone`) VALUES ('".$obj->nid."', '".$tomorrow."' , '".$tomorrow."', '308');";
            $result2 = db_query($sql);
        }
    } // end if sticky
    else {//else not sticky
        $sql = "SELECT `nid`,  FROM `event` WHERE `nid` = '".$obj->nid."'";
        $result2 = db_query($sql);
        if (!db_fetch_object($result2)) {
            $sql = "INSERT INTO `event` (`nid`, `event_start`, `event_end`, `timezone`) VALUES ('".$obj->nid."', '".$obj->created."' , '".$obj->created."', '308');";
            $result3 = db_query($sql);
        }
    
    }//end else not sticky
}

Any thoughts? Is there a more Drupal way to do this? Feedback would be appreciated.