}
return $queryParts;
});
+add_filter('get_county_by_city', function( $city ) {
+ global $wpdb;
+ $sql = "SELECT C.id FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."counties C "
+ . "WHERE C.id IN ("
+ . "SELECT M.county "
+ . "FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info M "
+ . "WHERE M.status = 10 "
+ . "AND M.city = $city "
+ . "AND NOT M.county = 0) "
+ . "LIMIT 1 "
+ . ";";
+ $results = $wpdb->get_var($sql);
+ return $results;
+
+}, 10, 1);
add_filter('glm-member-db-fields-front-list-query-params', function( $query ){
$queryParams = array();
// Check for manufactures
<div id="content-wrapper">
<div id="top-ad-container" class="row">
<?php
- // Do a query that grabs a county of a member that has this city AND a county set, AND is active,
- // and then check whether that county is in the list of counties for which an ad is supposed to be shown
- switch ($_REQUEST['cities'][0] ) {
-
- case 37: // Gaylord
+ // If a city is searched for, if it is one of certain cities, display the ad for that city.
+ // If it is not one of those cities check the county associated with the city searched for
+ // Otherwise, If a city is not searched for, check for the county that is searched for,
+ // then display the ad for that county
+ $county = 0;$city = 0;
+ if (isset($_REQUEST['cities'][0]) && $_REQUEST['cities'][0] > 0) {
+ $county = apply_filters("get_county_by_city", $_REQUEST['cities'][0]);
+ $city = $_REQUEST['cities'][0];
+ } else if (isset($_REQUEST['counties'][0]) && $_REQUEST['counties'][0] > 0) {
+ $county = $_REQUEST['counties'][0];
+ }
+ switch ($city) { // Find by city first, specific list given by client
+ case 37: // Gaylord County
echo do_shortcode("[the_ad id='1182']"); // Gaylord Area CVB
break;
- case 89: // Petoskey
+ case 89: // Petoskey County
echo do_shortcode("[the_ad id='1180']"); // Petoskey Area CVB
break;
- case 106: // Traverse City
+ case 106: // Traverse City County
echo do_shortcode("[the_ad id='1186']"); // Traverse City CVB
break;
- default:
- // If no city is specified, check whether a county if specified
- switch ($_REQUEST['counties'][0] ) {
- case 4: // Traverse City CVB: Antrim
- case 17: // Traverse City CVB: Grand Traverse
- case 38: // Traverse City CVB: Leelanau
- echo do_shortcode("[the_ad id='1186']"); // Traverse City CVB
+ default: // If a specific city override is not found, look at the county
+ switch ($county) {
+ case 40: // Crawford County
+ case 2: // Montmorency County
+ case 8: // Otsego County
+ echo do_shortcode("[the_ad id='1182']"); // Gaylord Area CVB
break;
- case 9: // Petoskey Area CVB: Charlevoix
- case 13: // Petoskey Area CVB: Emmet
+ case 9: // Charlevoix County
+ case 13: // Emmet County
echo do_shortcode("[the_ad id='1180']"); // Petoskey Area CVB
break;
- case 40: // Gaylord Area CVB: Crawford
- case 2: // Gaylord Area CVB: Montmorency
- case 8: // Gaylord Area CVB: Otsego
- echo do_shortcode("[the_ad id='1182']"); // Gaylord Area CVB
+ case 4: // Antrim County
+ case 17: // Grand Traverse County
+ case 38: // Leelanau County
+ echo do_shortcode("[the_ad id='1186']"); // Traverse City CVB
break;
default:
break; // No ads
}
break;
- } ?>
+ }
+ ?>
</div>
<div class="row">
<?php if(function_exists('bcn_display') && !is_front_page())