Display asset cluster maps in the farm map header block.
This commit is contained in:
parent
d792512680
commit
ae60c5f9c2
|
@ -56,16 +56,20 @@ function _farm_ui_views_post_render(&$view, &$output, &$cache) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Add the asset cluster map to the top of the View.
|
||||
$title = t('Asset cluster map');
|
||||
if (!empty($view->display['default']->display_options['title'])) {
|
||||
$asset_type_label = $view->display['default']->display_options['title'];
|
||||
$title = t('@asset_type cluster map', array('@asset_type' => $asset_type_label));
|
||||
}
|
||||
$fieldset = TRUE;
|
||||
$collapsed = TRUE;
|
||||
$map_build = farm_map_build('farm_assets_' . $bundle, $fieldset, $title, $collapsed);
|
||||
$output = drupal_render($map_build) . $output;
|
||||
// Add JS setting to set the bundle.
|
||||
$settings = array(
|
||||
'farm_map' => array(
|
||||
'behaviors' => array(
|
||||
'assets_full' => array(
|
||||
'type' => $bundle,
|
||||
),
|
||||
'assets_cluster' => array(
|
||||
'type' => $bundle,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
drupal_add_js($settings, array('type' => 'setting'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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']['status'] = TRUE;
|
||||
$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()) {
|
||||
$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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue