Skip to content

Commit

Permalink
Closes #3770: Add menu links to the /admin/config/az-quickstart page
Browse files Browse the repository at this point in the history
  • Loading branch information
joeparsons authored Oct 15, 2024
1 parent 7391eb5 commit 79ebac4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
20 changes: 19 additions & 1 deletion modules/custom/az_core/az_core.links.menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@ az_core.az_quickstart:
route_name: az_core.az_quickstart
parent: system.admin_config
title: 'Arizona Quickstart'
description: 'Settings provided by Arizona Quickstart modules.'
description: 'Settings provided by Arizona Quickstart modules'

az_core.az_settings:
route_name: az_core.az_settings
parent: az_core.az_quickstart
title: 'Arizona Quickstart Settings'
description: 'Settings provided by Quickstart Core and various other Arizona Quickstart modules.'

az_core.az_docs:
url: https://quickstart.arizona.edu
parent: az_core.az_quickstart
title: 'Documentation'
description: 'Arizona Quickstart 2 Documentation'
options:
attributes:
target: '_blank'

az_core.az_releases:
url: https://github.com/az-digital/az_quickstart/releases
parent: az_core.az_quickstart
title: 'Releases'
description: 'Arizona Quickstart 2 Releases'
options:
attributes:
target: '_blank'
48 changes: 33 additions & 15 deletions modules/custom/az_google_tag/az_google_tag.module
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,42 @@ use Drupal\Core\Url;
* Implements hook_toolbar_alter().
*/
function az_google_tag_toolbar_alter(&$items) {
if (\Drupal::service('module_handler')->moduleExists('az_core')) {
$site_url = \Drupal::request()->getHost();
$items['az_quickstart']['tray']['az_links']['#links']['analytics'] = [
'title' => t('Analytics Dashboard'),
'url' => Url::fromUri('https://lookerstudio.google.com/reporting/ef02c272-afe4-4862-b4bd-8706e3436b2f/page/nbaTD', [
'query' => [
'params' => '{"df21":"include%EE%80%800%EE%80%80IN%EE%80%80' . $site_url . '"}',
],
'absolute' => TRUE,
]),
'attributes' => [
'title' => t('Site Analytics Dashboard'),
'target' => t('_blank'),
],
];
if (\Drupal::service('module_handler')->moduleExists('az_core')) {
$items['az_quickstart']['tray']['az_links']['#links']['analytics'] = _az_google_tag_analytics_dashboard_link_info();
}
}

/**
* Implements hook_menu_links_discovered_alter().
*/
function az_google_tag_menu_links_discovered_alter(&$links) {
if (\Drupal::service('module_handler')->moduleExists('az_core')) {
$links['az_google_tag.analytics_dashboard'] = _az_google_tag_analytics_dashboard_link_info();
$links['az_google_tag.analytics_dashboard']['parent'] = 'az_core.az_quickstart';
$links['az_google_tag.analytics_dashboard']['description'] = t('Site Analytics Dashboard');
}
}

/**
* Returns analytics dashboard link info common to various render elements.
*/
function _az_google_tag_analytics_dashboard_link_info() {
$site_url = \Drupal::request()->getHost();
return [
'title' => t('Analytics Dashboard'),
'url' => Url::fromUri('https://lookerstudio.google.com/reporting/ef02c272-afe4-4862-b4bd-8706e3436b2f/page/nbaTD', [
'query' => [
'params' => '{"df21":"include%EE%80%800%EE%80%80IN%EE%80%80' . $site_url . '"}',
],
'absolute' => TRUE,
]),
'attributes' => [
'title' => t('Site Analytics Dashboard'),
'target' => t('_blank'),
],
];
}

/**
* Checks if the consent mode config setting is enabled for any Google Tags.
*
Expand Down

0 comments on commit 79ebac4

Please sign in to comment.