Display asset cluster maps in the farm map header block.

This commit is contained in:
Michael Stenta 2020-02-07 13:35:10 -05:00
parent d792512680
commit ae60c5f9c2
2 changed files with 20 additions and 11 deletions

View File

@ -56,16 +56,20 @@ function _farm_ui_views_post_render(&$view, &$output, &$cache) {
return; return;
} }
// Add the asset cluster map to the top of the View. // Add JS setting to set the bundle.
$title = t('Asset cluster map'); $settings = array(
if (!empty($view->display['default']->display_options['title'])) { 'farm_map' => array(
$asset_type_label = $view->display['default']->display_options['title']; 'behaviors' => array(
$title = t('@asset_type cluster map', array('@asset_type' => $asset_type_label)); 'assets_full' => array(
} 'type' => $bundle,
$fieldset = TRUE; ),
$collapsed = TRUE; 'assets_cluster' => array(
$map_build = farm_map_build('farm_assets_' . $bundle, $fieldset, $title, $collapsed); 'type' => $bundle,
$output = drupal_render($map_build) . $output; ),
),
),
);
drupal_add_js($settings, array('type' => 'setting'));
} }
/** /**

View File

@ -424,7 +424,7 @@ function farm_theme_block_info_alter(&$blocks, $theme, $code_blocks) {
$blocks['farm_map']['farm_map']['region'] = 'page_top'; $blocks['farm_map']['farm_map']['region'] = 'page_top';
$blocks['farm_map']['farm_map']['status'] = TRUE; $blocks['farm_map']['farm_map']['status'] = TRUE;
$blocks['farm_map']['farm_map']['visibility'] = BLOCK_VISIBILITY_LISTED; $blocks['farm_map']['farm_map']['visibility'] = BLOCK_VISIBILITY_LISTED;
$blocks['farm_map']['farm_map']['pages'] = '<front>'; $blocks['farm_map']['farm_map']['pages'] = "<front>\nfarm/assets/*";
} }
} }
@ -448,6 +448,11 @@ function farm_theme_block_view_alter(&$data, $block) {
if (drupal_is_front_page()) { if (drupal_is_front_page()) {
$data['content']['#map_name'] = 'farm_areas'; $data['content']['#map_name'] = 'farm_areas';
} }
// Or, if the block is on an asset listing page, show the farm_assets map.
elseif (strpos(current_path(), 'farm/assets/') === 0) {
$data['content']['#map_name'] = 'farm_assets';
}
} }
} }