From 540b1b93817378550aeeb02370ca845d97430534 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 17 Jan 2021 21:25:08 +0100 Subject: Add shortcodes to display (public) concert list. --- giglogadmin.php | 9 +++ includes/public/shortcodes/giglog_bands.php | 114 ++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 includes/public/shortcodes/giglog_bands.php diff --git a/giglogadmin.php b/giglogadmin.php index 977acbd..b5c45f9 100644 --- a/giglogadmin.php +++ b/giglogadmin.php @@ -18,8 +18,15 @@ */ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { + require_once __DIR__ . '/includes/public/shortcodes/giglog_bands.php'; + class GiglogAdmin_Plugin { + static public function init() { + add_shortcode('giglog_cities', 'giglogadmin_getfilters'); + add_shortcode('giglog_bands', 'giglogadmin_getconcerts'); + } + static function activate() { require_once __DIR__ . '/includes/admin/register_db_tables.php'; } @@ -30,5 +37,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { register_activation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'activate' )); register_deactivation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'deactivate' )); + + GiglogAdmin_Plugin::init(); } ?> diff --git a/includes/public/shortcodes/giglog_bands.php b/includes/public/shortcodes/giglog_bands.php new file mode 100644 index 0000000..226af14 --- /dev/null +++ b/includes/public/shortcodes/giglog_bands.php @@ -0,0 +1,114 @@ +get_results('select distinct wpgvenue_city from wpg_venues'); + $select = '
'; + //second drop down for venue + + $vquery = "select id, wpgvenue_name from wpg_venues"; + $vquery .= " where wpgvenue_city='" . $_POST["selectcity"] . "'"; + $resultsv = $wpdb->get_results($vquery); + $select .= '
'; + return $select; +} + + +function giglogadmin_getconcerts() +{ + global $wpdb; + // Shortcodes RETURN content, so store in a variable to return + $content = ''; + // $content .= ''; + $content .= ''; + // Use the submitted "city" if any. Otherwise, use the default/static value. + $cty = filter_input(INPUT_POST, 'selectcity'); + $cty = $cty ? $cty : 'ALL'; + + $venue = filter_input(INPUT_POST, 'selectvenue'); + //echo($_POST['selectvenue']); + $venue = $venue ? $venue : '0'; + + + $query = "SELECT wpgc.id, wpgb.wpgband_name as band ,wpgv.wpgvenue_name as venue ,wpgc.wpgconcert_date, wpgc.wpgconcert_tickets, wpgc.wpgconcert_event, wpgv.wpgvenue_city, wpgv.wpgvenue_webpage + FROM wpg_concerts wpgc, wpg_bands wpgb, wpg_venues wpgv +where wpgc.band=wpgb.id +and wpgc.venue = wpgv.id +and wpgconcert_date >= CURDATE()"; + $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" . $cty . "'"; + $query .= ($venue == "0") ? "" : " and wpgv.id='" . $venue . "'"; + $query .= " order by wpgv.wpgvenue_city, wpgconcert_date"; + //echo($query); + $results = $wpdb->get_results($query); + + + $lastType = ''; + foreach ($results AS $row) { + $content .= ''; + + if ($lastType != '' && $lastType != $row->wpgvenue_city) { + $content .= ''; + } + + if ($lastType == '') { + $content .= ''; + } + // Modify these to match the database structure + // $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $fdate = strtotime($row->wpgconcert_date); + $newformat = date('d.M.Y', $fdate); + + //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); + $content .= ''; + $content .= ''; + $content .= ''; + $content .= ''; + $lastType = $row->wpgvenue_city; + } + $content .= '
CITYIDBANDVENUEDATETICKETSEVENT
CITYBANDVENUEDATETICKETSEVENT
' . $row->wpgvenue_city . '
' . $row->wpgvenue_city . '
' . $row->id. '' . $row->band . '' . $row->venue . '' . $newformat . 'TicketsEvent link
'; + // return the table + return $content; +} -- cgit v1.2.3