$eventDay = null;
$pageSlug = 'event-detail';
$customPage = false;
+ $groupByDay = true;
+ $groupMonth = false;
// If there's a pageslug as attribute then update the pageSlug
if ( isset ( $actionData['request']['pageslug'] ) ) {
$search = true;
$action = 'event-detail';
}
+ if ( isset( $actionData['request']['group_by_day'] ) ) {
+ $groupByDay = filter_var( $actionData['request']['group_by_day'], FILTER_VALIDATE_BOOLEAN );
+ }
+ if ( isset( $actionData['request']['group_month'] ) ) {
+ $groupMonth = filter_var( $actionData['request']['group_month'], FILTER_VALIDATE_BOOLEAN );
+ }
if ( isset( $_REQUEST['category'] ) ) {
$categoryId = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT );
if ( $categoryId ) {
} else {
$fromDate = date('m/d/Y');
}
- if ( isset($_REQUEST['glm_event_to']) ) {
+ if ( isset($_REQUEST['glm_event_to']) && !$groupMonth ) {
$toDate = filter_var(
$_REQUEST['glm_event_to'],
FILTER_VALIDATE_REGEXP,
)
)
);
+ } else if ( $groupMonth ) {
+ // restrict the date to one month of events
+ if ( !isset( $_REQUEST['glm_event_from'] ) ) {
+ // use the first date for this month
+ $fromDate = date( 'm/d/Y', mktime( 0, 0, 0, date( 'n' ), 1, date( 'Y' ) ) );
+ }
+ if ( !isset( $_REQUEST['glm_event_to'] ) ) {
+ $toDate = date( 'm/d/Y', mktime( 0, 0, 0, date( 'n' ), date( 't' ), date( 'Y' ) ) );
+ }
+ echo '<pre>$fromDate: ' . print_r( $fromDate, true ) . '</pre>';
+ echo '<pre>$toDate: ' . print_r( $toDate, true ) . '</pre>';
} else if ( in_array($action, array( 'event-list-name', 'nameSearch', 'featured' ) ) || $this->config['settings']['use_venue_locations'] ) {
$toDate = null;
} else {
// group the events by the starting date
$eventsByDate = $mainEvents = array();
- if ( $events && $action != 'featured' && $action != 'current' ) {
+ if ( $events && $action != 'featured' && $action != 'current' && $groupByDay ) {
foreach ( $events as $event ) {
if ( isset( $event['times'] ) && is_array( $event['times'] ) ) {
foreach ( $event['times'] as $eventTime ) {
$years = array('current' => $current_year = date("Y"), 'next' => date('Y') +1 );
$months = [];
$count = 0;
-
+
foreach($years as $key=>$year){
// if member id we need to limit the dates for month dropdown by member id
if($memberId){
}
// otherwise we can just pull all of the dates for the events as usual
} else {
-
+
if($current_year == $year){
$sql = 'SELECT MONTH(start_time) as month FROM '. GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX .'times ';
$sql .= "WHERE YEAR(start_time) = $year AND MONTH(start_time) >= MONTH(CURDATE()) GROUP BY month";
$results[$year] = $wpdb->get_results($sql, ARRAY_A);
}
}
-
+
}
foreach($results as $year => $month){
foreach($month as $key=>$value){