From e000ef821b36c80e58458b6ad4e8d61cac29ae94 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Fri, 4 Jun 2021 22:39:13 -0400 Subject: [PATCH] Include asset name in asset/%/children and asset/%/assets page titles. --- .../ui/views/farm_ui_views.views_execution.inc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/ui/views/farm_ui_views.views_execution.inc b/modules/ui/views/farm_ui_views.views_execution.inc index b6d8ac73..7d0fc211 100644 --- a/modules/ui/views/farm_ui_views.views_execution.inc +++ b/modules/ui/views/farm_ui_views.views_execution.inc @@ -71,6 +71,22 @@ function farm_ui_views_views_pre_render(ViewExecutable $view) { // We may set the View page title, but assume not. $title = ''; + // If this is the farm_asset View and page_children display, include the + // asset's name. + if ($view->id() == 'farm_asset' && $view->current_display == 'page_children') { + $asset_id = $view->args[0]; + $asset = \Drupal::entityTypeManager()->getStorage('asset')->load($asset_id); + $title = t('Children of %asset', ['%asset' => $asset->label()]); + } + + // If this is the farm_asset View and page_location display, include the + // asset's name. + if ($view->id() == 'farm_asset' && $view->current_display == 'page_location') { + $asset_id = $view->args[0]; + $asset = \Drupal::entityTypeManager()->getStorage('asset')->load($asset_id); + $title = t('Assets in %location', ['%location' => $asset->label()]); + } + // If this is the farm_log View and page_asset display, include the asset's // name. if ($view->id() == 'farm_log' && $view->current_display == 'page_asset') {