major: remove need for several templates, simplify code, CF & admin use
authorLaury GvR <laury@gaslightmedia.com>
Thu, 14 Feb 2019 22:21:31 +0000 (17:21 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 14 Feb 2019 22:25:26 +0000 (17:25 -0500)
- GLM Associate template now takes care of its sidebar through the
  glma setting of 'sidebar area'. Now these pages can use the
 'no-sidebar' template
- Gallery Template was essentially already using a no-sidebar
  template
- This all is achieved by allowing 'Top Content' CF on any template
  rather than only on Gallery Templates, as is required by the
  request to be able to show a gallery using Top Content on
  GLM Associate template pages (and virtually any page)
- Reduced 'default' code in Interior Page file, as a big part of
  this is now handled in the County Landing template

county-child-page-template.php [deleted file]
sections/interior-page.php

diff --git a/county-child-page-template.php b/county-child-page-template.php
deleted file mode 100644 (file)
index 41cefe7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-/*
-Template Name: County Child Page
-*/
-get_template_part('index');
\ No newline at end of file
index e5066ef..931e274 100644 (file)
@@ -1,14 +1,10 @@
 <?php 
     $countyCatId = false;
     $countyPageId = -1;
-?>
-
-<?php
     // Find template - remove file extension for easier checking. Assign container class based on template
     $template = str_replace( ".php", "", get_page_template_slug( $post->ID ) );
-    
 ?>
-<main class="page-inside <?php echo $template ?: 'default-template';?>>
+<main class="page-inside <?php echo ($template ?: 'default-template');?>">
     <?php if ( is_in_tree( COUNTIES_PAGE_ID ) ) { ?>
 
         <?php 
@@ -18,9 +14,9 @@
         
         <?php if ( $countyChildren ) {
             if(strpos(get_the_title($post->ID), 'Water') !== false ){
-                $memberCategory = '25'; // L: 3, dev70: 25
+                $memberCategory = '3'; // L: 3, dev70: 25
             } else if(strpos(get_the_title($post->ID), 'Light') !== false ){
-                $memberCategory = '21'; // L: 4, ddev70: 21
+                $memberCategory = '4'; // L: 4, ddev70: 21
             } else {
             }
         } ?>
         <?php 
             if ( $countyPageId && function_exists("get_field") ) {
                 if ( get_field( 'member_county_id' ) ) {
-                    // $debugMsg[] = "using count page id";
+                    // using county page id
                     $memberCountyId = get_field( 'member_county_id' );
                 } else if ( get_field( 'member_county_id', wp_get_post_parent_id( $post ) ) ) {
-                    // $debugMsg[] = "using county page id of parent";
+                    // using county page id of parent
                     $memberCountyId = get_field( 'member_county_id', wp_get_post_parent_id( $post ) );
-                    // $debugMsg[] = "membercountyid var value: $memberCountyId";
                 } else {
-                    // $debugMsg[] = "no county page id?";
+                    // no county page id
+                    $memberCountyId = false;
                 }
             }
         ?>
-    <?php } else {
-        // $debugMsg[] = "Im not in the county tree";
-     } ?>
+    <?php } ?>
     <?php 
         // Find out what header to show;
         // - county landing page:   crowdriff script from custom field
         // - county sub page:       member db map for that county from custom field
         // - any other page:        crowdriff script from custom field if exists,
         // ---  otherwise featured image if exists
-        //$debugMsg[] = "Is county child? " . ($isCountyChildPage ? 'true' : 'false') . " - member county pageID: " . $countyPageId;
     ?>
     
-    
     <?php if ( (wp_get_post_parent_id( $post ) == COUNTIES_PAGE_ID) && ( function_exists('the_field') && get_field('interior_header_crowdriff_script',$post->ID) )) { ?>
         <div id="header-crowdriff">
             <?php echo the_field('interior_header_crowdriff_script',$post->ID); ?>
             <?php echo glm_get_header(); ?>
         </div>
     <?php } ?>
-           
-    <?php 
-        foreach ($debugMsg as $k) {
-            //echo "<br>$k";
-        }
-    ?>
 
     <div id="content-wrapper">
+
+        <?php if ( get_field( "top_content" ) ) { ?>
+            <div class="row">
+                <div class="small-12 columns">
+                    <?php echo the_field('top_content',$post->ID); ?>
+                </div>
+            </div>
+        <?php } ?>
         <?php switch($template){
             case "glm-members-only-template": ?>
                 <div class="row">
                     <div class="members-only-template large-8 columns" data-equalizer-watch>
                         <?php if (!is_user_logged_in()) { ?>
                             <!-- If user is logged in as a member, display top bar, bread crumbs, & content -->
-                            <?php get_template_part('parts/glm-members-only-top-bar');
-                            get_template_part('parts/main-content');
-                        } else {
-                            get_template_part('parts/glm-members-only-login-form');
-                        } ?>
+                            <?php get_template_part('parts/glm-members-only-top-bar'); ?>
+
+                            <?php if ( get_field( "top_content" ) ) { ?>
+                                <div class="row">
+                                    <div class="small-12 columns">
+                                        <?php echo the_field('top_content',$post->ID); ?>
+                                    </div>
+                                </div>
+                            <?php } ?>
+                            <?php get_template_part('parts/main-content'); ?>
+                        <?php } else { ?>
+                            <?php get_template_part('parts/glm-members-only-login-form'); ?>
+                        <?php } ?>
                     </div>
                     <div class="small-12 large-4 columns">
                         <?php get_sidebar(); ?>
                 </div>
             <?php break; ?>
 
-            <?php case "gallery-template": ?>
-                <div class="row">
-                    <div class="small-12 columns">
-                        <?php echo the_field('top_content',$post->ID); ?>
-                    </div>
-                </div>
-                <div class="row full-width">
-                    <div class="small-12 columns">
-                        <?php echo the_field('member_db_shortcode',$post->ID); ?>
-                    </div>
-                </div>
-                <div class="row">
-                    <div class="small-12 columns">
-                        <?php get_template_part('parts/main-content'); ?>
-                    </div>
-                </div>
-            <?php break; ?>
-            
-            <?php case "events-template": ?>
-                <div class="row">
-                    <?php get_template_part('parts/main-content'); ?>
-                </div>
-                <div class="row full-width">
-                <?php get_template_part("parts/events-feed"); ?>
-                </div>
-                <div class="row">
-                    <?php echo the_field('member_db_shortcode',$post->ID); ?>
-                </div>
-            <?php break; ?>
-
-            <?php case "glm-associate-template": ?>
-                <div class="row">
-                    <div class="small-12 columns">
-                        <?php get_template_part('parts/main-content'); ?>
-                    </div>
-                </div>
-                <div class="row full-width">
-                    <div class="small-12 columns">
-                        <?php echo the_field('member_db_shortcode',$post->ID); ?>
-                    </div>
-                </div>
-            <?php break; ?>
-
             <?php case "no-sidebar-template": ?>
                 <div class="row">
                     <div class="small-12 columns" data-equalizer-watch>
                     </div>
                 </div>
             <?php break; ?>
+
             <?php case "county-landing-page-template": ?>
                 <?php include(locate_template('sections/county-landing-page.php')); ?>
             <?php break; ?>
-
-            <?php case "no-sidebar-template": ?>
-                <div class="row">
-                    <div class="small-12 columns" data-equalizer-watch>
-                        <?php get_template_part('parts/main-content');?>
-                    </div>
-                </div>
-            <?php break; ?>
             
             <?php default: ?>
                 <div class="row">
                     <div class="small-12 large-8 columns" data-equalizer-watch>
-                        <?php if ( wp_get_post_parent_id( $post ) == COUNTIES_PAGE_ID ) { ?>
-                            <?php // if this is a county landing page, wrap content in expandable area, with member list below it ?>
-                            <div id="county-content-expand-section">
-                                <?php get_template_part('parts/main-content'); ?>
-                            </div>
-                            <div id="county-content-expand-button">Show More</div>
-                            <?php if ( $memberCountyId ) { ?>
-                                <?php // If the county ID is set in the county page's custom field, show the member list appropriate for that county ?>
-                                <br>
-                                <?php echo do_shortcode("[glm-members-list view='map' county-search='". $memberCountyId ."']"); ?>
-                            <?php } ?>
-                        <?php } else if ( $memberCountyId && $memberCategory) { ?>
-                                <?php // if parent isn't counties page, but membercountyid & category are still set, we're on a county child page - show content & list ?>
-                                <?php get_template_part('parts/main-content'); ?>
-                                <br>
-                                <?php echo do_shortcode("[glm-members-list show='-map,-search' category='". $memberCategory ."' county-search='". $memberCountyId ."']"); ?>
-                        <?php } else { ?>
-                            <?php get_template_part('parts/main-content'); ?>
+                        <?php get_template_part('parts/main-content'); ?>
+                        <?php if ( $memberCategory && $memberCountyId) { ?>
+                            <?php // If this is a county child page ?>
+                            <br>
+                            <?php echo do_shortcode("[glm-members-list show='-map,-search' category='". $memberCategory ."' county-search='". $memberCountyId ."']"); ?>
                         <?php } ?>
                     </div>
                     <div class="small-12 large-4 columns">