From a16e192fc34fc55293be453cbb7da4ad4bd2ed4a Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 12 Aug 2021 10:28:58 -0400 Subject: [PATCH] Adds new "Location 2021" template ** Why are these changes being introduced: * With the re-opening of the Hayden Library after its renovation, there is a desire to showcase content on its page that is not supported by our current location template. However, the changes coming for this page would not be appropriate for other current location pages. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/UXWS-1205 ** How does this address that need: * This adds a second template option for location pages. This will allow pages to be converted from the old to new format individually, as their content is updated for the new layout. * Specifically, this adds page-location-2021.php, which is identified as "Location (2021) Template" in the WordPress page editor. This page template then loads content-location-2021.php, following the pattern used elsewhere in the theme. * Some styles specific to this new template are also added to the _locations SCSS partial. * The file comments for the legacy location content has been updated. ** Document any side effects to this change: * In order for a successful deployment, two configuration changes will be necessary within the Advanced Custom Fields plugin. Specifically: 1. The "Location" field group will need to be edited to show on this new page template, not just the legacy template. 2. The "Location Attributes" field group will need a new field added, named "content_top_2021". This will be a WYSIWYG field. * CodeClimate is currently flagging ~80 issues in the new template, which are holdovers from the legacy template. Most are stylistic concerns, but the lack of content escaping may need discussion. There is a ticket in the UX backlog to coordinate this work later: UXWS-1206. * The stylesheet changes in this PR include some copy-paste of styles defined elsewhere, with new selector rules. An example is the .tabcontent class, which is defined for small screen widths in _tabs. This new template will need those styles for all screen widths. * The theme version is bumped to 1.12.0. --- content-location-2021.php | 173 +++++++++++++++++++++++++++++++++++ content-location.php | 2 +- css/partials/_locations.scss | 32 +++++++ css/style.css | 2 +- functions.php | 2 +- page-location-2021.php | 48 ++++++++++ page-location.php | 7 +- style.css | 2 +- 8 files changed, 260 insertions(+), 8 deletions(-) create mode 100644 content-location-2021.php create mode 100644 page-location-2021.php diff --git a/content-location-2021.php b/content-location-2021.php new file mode 100644 index 00000000..2ebd1e0a --- /dev/null +++ b/content-location-2021.php @@ -0,0 +1,173 @@ +post_name; + +$subject = cf( 'subject' ); +$phone = cf( 'phone' ); +$email = cf( 'email' ); +$building = cf( 'building' ); +$spaces = cf( 'group_spaces' ); +$arexpert = get_field( 'expert' ); + +$content_top_2021 = get_field( 'content_top_2021' ); + +$content1left = get_field( 'tab_1_content_left' ); +$content1 = get_field( 'tab_1_content' ); + +$content1wide = 0; +if ( '' === $content1 ) { + $content1wide = 1; +} + +$study24 = get_field( 'study_24' ); + +$expertAskUrl = get_field( 'expert_ask_url' ); +if ( '' === $expertAskUrl ) { + $expertAskUrl = 'http://libraries.mit.edu/ask'; +} + +// Populate the array of available main images. +$numMain = 6; +$arMain = array(); +for ( $i = 1;$i <= $numMain;$i++ ) { + $img = get_field( 'main_image' . $i, $locationId ); + if ( '' !== trim( $img ) ) { + $arMain[] = $img; + } +} + +// Populate the array of available sub images. +$numSub = 8; +$arSub = array(); +$subs = 0; +for ( $i = 1;$i <= $numSub;$i++ ) { + $img = get_field( 'sub_image' . $i, $locationId ); + if ( '' !== trim( $img ) ) { + $subs++; + $arSub[] = $img; + } +} + +$strLocation = ''; +if ( 0 >= $subs ) { + $strLocation = 'noThumbs'; +} + +$alertTitle = cf( 'alert_title' ); +$alertContent = cf( 'alert_content' ); +?> + +
+ ' . '
' . '
' . '

' . $alertTitle . '

' . '

' . $alertContent . '

' . '
' . '
' . '
'; + } + ?> + +
+
+
+

+ + +

+
+ | + + | + + Room: +
+
+ +
+ Today's hours: + + | Study 24/7 + + See all hours +
+
+
+
+ + + <?php the_title(); ?> + +
+
+
+ +
+
+
+
+ +
+ + post_title; + $bio = $expert->post_excerpt; + // $url = $expert->guid; + $url = get_post_meta( $expert->ID, 'expert_url', 1 ); + + if ( has_post_thumbnail( $expert->ID ) ) { + $thumb = get_the_post_thumbnail( $expert->ID, array( 108, 108 ) ); + } else { + $thumb = ''; + } + + ?> +
+ +
+

+ Featured expert + + +

+ + +
+ +
+ + + +
+ +
+ + +
+ +
+
+
diff --git a/content-location.php b/content-location.php index e8b9f850..39c19e76 100644 --- a/content-location.php +++ b/content-location.php @@ -1,6 +1,6 @@ ID == $post->ID; + +get_header(); ?> + + + + $objs->ID, + 'post_type' => 'any', +); + +$location_posts = new WP_Query( $args ); +?> + +
+ + have_posts() ) : + $location_posts->the_post(); + ?> + + + + + +
+ + diff --git a/page-location.php b/page-location.php index 478e6dbe..2144ef96 100644 --- a/page-location.php +++ b/page-location.php @@ -2,10 +2,9 @@ /** * Template Name: Location Template * - * This is the template that displays all pages by default. - * Please note that this is the WordPress construct of pages - * and that other 'pages' on your WordPress site will use a - * different template. + * This is the template that displays location records, which have a number + * of custom fields defined by the ACF plugin. This template was designed + * prior to 2021, and is a legacy layout. * * @package MIT_Libraries_Parent * @since 1.2.1 diff --git a/style.css b/style.css index 138a4236..3ed056c0 100644 --- a/style.css +++ b/style.css @@ -2,7 +2,7 @@ Theme Name: MIT Libraries Author: Lightning Trumpet Author URI: http://wordpress.org/ -Version: 1.11.1-@@branch-@@commit +Version: 1.12.0-@@branch-@@commit MIT Libraries theme built for the MIT Libraries website.