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

Closes #3770: Add menu links to the /admin/config/az-quickstart page #3776

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 23 additions & 2 deletions modules/custom/az_core/az_core.links.menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,31 @@ 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.'
description: 'Settings provided by Quickstart Core and various other Arizona Quickstart modules'
weight: 0

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'
weight: 2

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'
weight: 1
47 changes: 40 additions & 7 deletions modules/custom/az_google_tag/az_google_tag.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ use Drupal\Core\Url;
*/
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,
]),
'url' => _az_google_tag_analytics_dashboard_url(),
'attributes' => [
'title' => t('Site Analytics Dashboard'),
'target' => t('_blank'),
Expand All @@ -29,6 +23,45 @@ function az_google_tag_toolbar_alter(&$items) {
}
}

/**
* 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'] = [
'title' => t('Analytics Dashboard'),
'url' => _az_google_tag_analytics_dashboard_url()->toString(),
'parent' => 'az_core.az_quickstart',
'description' => t('Site Analytics Dashboard'),
'options' => [
'attributes' => [
'title' => t('Site Analytics Dashboard'),
'target' => t('_blank'),
],
],
];
}
}

/**
* Returns analytics dashboard link info common to various render elements.
*
* @return \Drupal\Core\Url
* URL object for site-specific Analytics Dashboard URL.
*/
function _az_google_tag_analytics_dashboard_url() {
$site_url = \Drupal::request()->getHost();
return 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,
]
);
}

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