Sidebar events specific display parameters:
authorLaury GvR <laury@gaslightmedia.com>
Tue, 12 Feb 2019 19:05:20 +0000 (14:05 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 12 Feb 2019 19:05:20 +0000 (14:05 -0500)
- INT val will show sidebar and show events for that region,
  occurs when on member detail and region is found
- FALSE val will show sidebar and cause region flag to ignore,
  occurs when not on member detail (show events from all regions)
- NULL val will make sidebar events not show, occurs when we are
  on member detail but no region found

sidebar.php

index 96df2af..08675e4 100644 (file)
             </div>
         <?php } ?>
 
-    <?php $memberRegion = apply_filters('get-current-memberinfo-field', 'region');?>
-    <div id="sidebar-events">
-        <h2>Upcoming Events</h2>
-        <?php echo do_shortcode('[glm-members-event-list template="eventsFrontPageCity.html" region-search="'. $memberRegion .'" limit="3"]'); ?>
-        <a href="<?php echo get_permalink(757); ?>" class="button view-all-events">View All Events</a>
-    </div>
+    <?php
+        if ( !isset($GLOBALS['glmDetailSlug']) || !$GLOBALS['glmDetailSlug'] ) {
+            $memberRegion = false; // If not on a member detail page, return events from all regions
+        } else {
+            $memberRegion = apply_filters('get-current-memberinfo-field', 'region'); // returns null if no region found
+        }
+    ?>
+    <?php 
+        // Only show sidebar if memberRegion is set. 
+        // - INT val will show sidebar and show events for that region, occurs when on member detail and region is found
+        // - FALSE val will show sidebar and cause region flag to ignore, occurs when not on member detail (show events from all regions)
+        // - NULL val will make sidebar events not show, occurs when we are on member detail but no region found
+    ?>
+    <?php if ( isset($memberRegion) ) { ?>
+        <div id="sidebar-events">
+            <h2>Upcoming Events</h2>
+            <?php echo do_shortcode('[glm-members-event-list template="eventsFrontPageCity.html" region-search="'. $memberRegion .'" limit="3"]'); ?>
+            <a href="<?php echo get_permalink(757); ?>" class="button view-all-events">View All Events</a>
+        </div>
+    <?php } ?>
     
     <br>