diff --git a/boulder_base.theme b/boulder_base.theme index 6c6a4830..c642e325 100755 --- a/boulder_base.theme +++ b/boulder_base.theme @@ -355,6 +355,26 @@ function boulder_base_form_system_theme_settings_alter(&$form, FormStateInterfac } } +/** + * Implements hook_preprocess_views_view(). + */ +function boulder_base_preprocess_views_view(&$variables) { + // Adjust header content for the taxonomy_term view. + // Needed because the Full HTML text filter doesn't escape special HTML entities like & + if ($variables['view']->id() === 'taxonomy_term') { + if (isset($variables['header']['area']['#text'])) { + // Decode HTML entities in the header text. + $variables['header']['area']['#text'] = html_entity_decode($variables['header']['area']['#text']); + } + } +} + + + + + + + /** * This is for list styles during migration. */ diff --git a/css/block/ucb-article-list-block.css b/css/block/ucb-article-list-block.css index 86c56daa..e5a68eb8 100644 --- a/css/block/ucb-article-list-block.css +++ b/css/block/ucb-article-list-block.css @@ -76,6 +76,11 @@ margin: 0; line-height: 1.3; } + +.ucb-article-card-title-no-date{ + margin-bottom: 12px; +} + .ucb-article-card-title-feature { font-size: 130%; font-weight: bolder; diff --git a/css/ucb-taxonomy-page.css b/css/ucb-taxonomy-page.css index 8b2fb22c..550cb7e4 100644 --- a/css/ucb-taxonomy-page.css +++ b/css/ucb-taxonomy-page.css @@ -38,14 +38,16 @@ font-size: 85%; line-height: 85%; margin-bottom: 10px; + margin-top: 5px; } .ucb-taxonomy-title { font-size: 120%; font-weight: normal; + padding-bottom: 10px; margin-bottom: 10px; line-height: 1.3; - margin: 0 0 10px 0; + margin: 0; } .ucb-taxonomy-thumbnail { @@ -71,7 +73,6 @@ .ucb-newsletter-row{ margin-bottom: 20px; - border-bottom: 1px solid rgba(128, 128, 128, 0.333); padding-bottom: 20px; } diff --git a/js/ucb-article-list-block.js b/js/ucb-article-list-block.js index d5388075..4618bed0 100644 --- a/js/ucb-article-list-block.js +++ b/js/ucb-article-list-block.js @@ -6,7 +6,7 @@ class ArticleListBlockElement extends HTMLElement { var display = this.getAttribute("display"); var API = this.getAttribute("jsonapi"); this._baseURI = this.getAttribute("base-uri"); - + this.globalDateSetting = this.getAttribute('global-date-format'); // Exclusions are done on the JS side, get into arrays. Blank if no exclusions var excludeCatArray = this.getAttribute("exCats").split(",").map(Number); var excludeTagArray = this.getAttribute("exTags").split(",").map(Number); @@ -119,10 +119,14 @@ class ArticleListBlockElement extends HTMLElement { link: this._baseURI + path, image: imageSrc, imageWide: imageSrcWide, - date: new Date(item.attributes.created).toLocaleDateString( - "en-us", - { year: "numeric", month: "short", day: "numeric" } - ), + date: (item.attributes.field_ucb_article_date_override != "7" && + (this.globalDateSetting != 6 || item.attributes.field_ucb_article_date_override != "0")) + ? new Date(item.attributes.created).toLocaleDateString('en-us', { + year: 'numeric', + month: 'short', + day: 'numeric', + }) + : null, body: body.trim(), }; } @@ -288,13 +292,18 @@ class ArticleListBlockElement extends HTMLElement { var articleHeader = document.createElement("h3"); articleHeader.classList = "ucb-article-card-title-feature"; + if(!articleDate){ + articleHeader.classList.add("ucb-article-card-title-no-date"); + } articleHeader.innerText = articleTitle; headerLink.appendChild(articleHeader); - var date = document.createElement("span"); - date.classList = "ucb-article-card-date"; - date.innerText = articleDate; + if(articleDate){ + var date = document.createElement("span"); + date.classList = "ucb-article-card-date"; + date.innerText = articleDate; + } var articleSummary = document.createElement("p"); articleSummary.innerText = articleSumm; @@ -307,7 +316,7 @@ class ArticleListBlockElement extends HTMLElement { readMore.setAttribute("aria-hidden", "true"); articleBody.appendChild(headerLink); - articleBody.appendChild(date); + if (articleDate){articleBody.appendChild(date)}; articleBody.appendChild(articleSummary); articleBody.appendChild(readMore); @@ -359,13 +368,18 @@ class ArticleListBlockElement extends HTMLElement { var articleHeader = document.createElement("h3"); articleHeader.classList = "ucb-article-card-title-feature"; + if(!articleDate){ + articleHeader.classList.add("ucb-article-card-title-no-date"); + } articleHeader.innerText = articleTitle; headerLink.appendChild(articleHeader); - var date = document.createElement("span"); - date.classList = "ucb-article-card-date"; - date.innerText = articleDate; + if(articleDate){ + var date = document.createElement("span"); + date.classList = "ucb-article-card-date"; + date.innerText = articleDate; + } var articleSummary = document.createElement("p"); articleSummary.innerText = articleSumm; @@ -378,7 +392,7 @@ class ArticleListBlockElement extends HTMLElement { readMore.setAttribute("aria-hidden", "true"); articleBody.appendChild(headerLink); - articleBody.appendChild(date); + if(articleDate){articleBody.appendChild(date)}; articleBody.appendChild(articleSummary); articleBody.appendChild(readMore); @@ -514,14 +528,19 @@ class ArticleListBlockElement extends HTMLElement { var articleHeader = document.createElement("a"); articleHeader.classList = "ucb-article-card-title-teaser"; + if(!articleDate){ + articleHeader.classList.add("ucb-article-card-title-no-date"); + } articleHeader.href = articleLink; articleHeader.innerText = articleTitle; headerStrong.appendChild(articleHeader); - var date = document.createElement("span"); - date.classList = "ucb-article-card-date"; - date.innerText = articleDate; + if(articleDate){ + var date = document.createElement("span"); + date.classList = "ucb-article-card-date"; + date.innerText = articleDate; + } var articleSummary = document.createElement("p"); articleSummary.innerText = articleSumm; @@ -534,7 +553,7 @@ class ArticleListBlockElement extends HTMLElement { readMore.setAttribute("aria-hidden", "true"); articleBody.appendChild(headerStrong); - articleBody.appendChild(date); + if(articleDate){articleBody.appendChild(date)}; articleBody.appendChild(articleSummary); articleBody.appendChild(readMore); diff --git a/js/ucb-article-list.js b/js/ucb-article-list.js index e7d964d6..40221cc1 100644 --- a/js/ucb-article-list.js +++ b/js/ucb-article-list.js @@ -19,7 +19,6 @@ this.pageCount = pageCount; this._categoryTerms = null; this._tagTerms = null; - // Build the endpoint path, now in JS this.endpoint = this.buildEndpointPath(); } @@ -189,6 +188,8 @@ this._filterFormElement.style.alignItems = 'center'; this._contentElement.setAttribute('aria-live', 'polite'); } + // Date format + this.globalDateSetting = this.getAttribute('global-date-format'); this.appendChild(this._contentElement); // Loader this._loadingElement = document.createElement('div'); @@ -530,12 +531,15 @@ imageSrc = altObj[idObj[thumbId]]; } - // Format date - const date = new Date(item.attributes.created).toLocaleDateString('en-us', { - year: 'numeric', - month: 'short', - day: 'numeric', - }); + // Format + const date = (item.attributes.field_ucb_article_date_override != "7" && + (this.globalDateSetting != 6 || item.attributes.field_ucb_article_date_override != "0")) + ? new Date(item.attributes.created).toLocaleDateString('en-us', { + year: 'numeric', + month: 'short', + day: 'numeric', + }) + : null; const title = item.attributes.title; // If no path alias set, use defaults const path = item.attributes.path.alias ? item.attributes.path.alias : `/node/${item.attributes.drupal_internal__nid}`; diff --git a/templates/block/block--article-list-block.html.twig b/templates/block/block--article-list-block.html.twig index 9db1f9de..272c72f7 100644 --- a/templates/block/block--article-list-block.html.twig +++ b/templates/block/block--article-list-block.html.twig @@ -15,6 +15,9 @@ {# Base Url #} {% set baseurlJSON = url('')|render|trim('/') %} +{# Show/Hide Date #} +{% set global_date_format = drupal_config('ucb_site_configuration.settings', 'article_date_format') %} + {# This block mirrors the Article List Node - constructs a JSON endpoint in TWIG using include filters #} {# JSON API Endpoint information #} {% set articlesJSON = (url('')|render|trim('/')) @@ -179,7 +182,9 @@ exCats="{{ excludeCategories }}" exTags="{{ excludeTags }}" display="{{ content.field_art_list_block_display|render|striptags|trim }}" - count="{{ content.field_art_list_block_item_count|render|striptags|trim }}"> + count="{{ content.field_art_list_block_item_count|render|striptags|trim }}" + global-date-format="{{global_date_format}}" + >
diff --git a/templates/content/node--ucb-article-list.html.twig b/templates/content/node--ucb-article-list.html.twig index 908ee20f..69f38d9d 100644 --- a/templates/content/node--ucb-article-list.html.twig +++ b/templates/content/node--ucb-article-list.html.twig @@ -72,6 +72,9 @@ {# Base Url #} {% set baseurlJSON = url('')|render|trim('/') %} +{# Show/Hide Date #} +{% set global_date_format = drupal_config('ucb_site_configuration.settings', 'article_date_format') %} + {# include and exclude options set by the user #} {% set includeCategories = '' %} {% set myCategories = content.field_ucb_filter_by_category|render|striptags|trim|split(' ') %} @@ -149,6 +152,7 @@ 'exclude-tags': excludeTags, 'expose-categories' : exposeCategory, 'expose-tags': exposeTag, + 'global-date-format': global_date_format, }) }} >