Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usagov 1685 fix site banner #1769

Draft
wants to merge 25 commits into
base: dev
Choose a base branch
from
Draft
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
36ac5be
USAGOV-1685-Fix-Site-banner: Testing cache
YaritzaGarcia Jul 26, 2024
1491687
USAGOV-1685-Fix-Site-banner: Merge branch 'dev' into USAGOV-1685-Fix-…
YaritzaGarcia Jul 26, 2024
8c1ae10
USAGOV-1685-Fix-Site-banner: Issue fixed. Added new if statement that…
YaritzaGarcia Jul 26, 2024
07c9f75
Merge branch 'dev' into USAGOV-1685-Fix-Site-banner
YaritzaGarcia Jul 30, 2024
87b4367
USAGOV-1685-Fix-Site-banner: Fix lint errors and remove comment
YaritzaGarcia Jul 30, 2024
f4c3338
Merge branch 'dev' into USAGOV-1685-Fix-Site-banner
akf Jul 31, 2024
37416cf
Merge branch 'dev' into USAGOV-1685-Fix-Site-banner
YaritzaGarcia Jul 31, 2024
0437155
USAGOV-1685-Fix-Site-banner: Moving the logic to another hook, still …
YaritzaGarcia Aug 1, 2024
2a3dc1c
USAGOV-1685-Fix-Site-banner: old testing stuff
YaritzaGarcia Aug 2, 2024
42eb5a5
USAGOV-1685-Fix-Site-banner: Merge branch 'dev' into USAGOV-1685-Fix-…
YaritzaGarcia Aug 5, 2024
e3ff3f9
USAGOV-1685-Fix-Site-banner: Merge branch 'dev' into USAGOV-1685-Fix-…
YaritzaGarcia Aug 13, 2024
23f906a
USAGOV-1685-Fix-Site-banner: Merge branch 'dev' into USAGOV-1685-Fix-…
YaritzaGarcia Aug 16, 2024
ba57bd8
USAGOV-1685-Fix-Site-banner: testing
YaritzaGarcia Aug 19, 2024
9ccff1f
Merge branch 'dev' into USAGOV-1685-Fix-Site-banner
YaritzaGarcia Aug 20, 2024
69e63f1
USAGOV-1685-Fix-Site-banner: Working. Placing the block by creating i…
YaritzaGarcia Aug 23, 2024
dd38546
USAGOV-1685-Fix-Site-banner: Move everything to a separate module and…
YaritzaGarcia Aug 23, 2024
b927650
USAGOV-1685-Fix-Site-banner: Fix lint errors
YaritzaGarcia Aug 23, 2024
7bbd9c0
USAGOV-1685-Fix-Site-banner: FIX LINT ERRORS
YaritzaGarcia Aug 23, 2024
701abce
USAGOV-1685-Fix-Site-banner: Merge branch 'dev' into USAGOV-1685-Fix-…
YaritzaGarcia Aug 23, 2024
c1a5eed
USAGOV-1685-Fix-Site-banner: Install new site banner module
YaritzaGarcia Aug 23, 2024
f839cdf
USAGOV-1685-Fix-Site-banner: Fix condition in functions
YaritzaGarcia Aug 23, 2024
c713225
USAGOV-1685-Fix-Site-banner: Update readme
YaritzaGarcia Aug 29, 2024
91d875e
Merge branch 'dev' into USAGOV-1685-Fix-Site-banner
YaritzaGarcia Aug 29, 2024
2d3986c
USAGOV-1685-Fix-Site-banner: Fix error in readme
YaritzaGarcia Aug 29, 2024
066d1b0
Merge branch 'dev' into USAGOV-1685-Fix-Site-banner
akf Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions web/modules/custom/usa_twig_vars/usa_twig_vars.module
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ function usa_twig_vars_preprocess_views_view_list__federal_agencies(&$variables,
*/
function usa_twig_vars_preprocess_region(&$variables) {

$state = \Drupal::state();

// Check if we are in the `header_top` region
if ($variables['region'] === 'header_top') {

Expand All @@ -299,11 +301,20 @@ function usa_twig_vars_preprocess_region(&$variables) {
if ($place_above_header) {
// Set the value to the site_banner id to add the site_banner to the `header_top` region.
$variables['site_banners'][$site_banner->id()] = $site_banner->id();

// Clear the cache only if the block is not placed in the region and the "Place above header" checkbox is selected.
if (!$state->get('site_banners_placement.' . $site_banner->id(), FALSE)) {
$state->set('site_banners_placement.' . $site_banner->id(), TRUE);
drupal_flush_all_caches();
}

}
else {
// Set the value to null to remove the site_banner with id `$site_banner->id()` from the region `header_top`
$variables['site_banners'][$site_banner->id()] = NULL;
$state->set('site_banners_placement.' . $site_banner->id(), FALSE);
}

}

}
Expand Down