You are here

function farm_theme_block_view_alter in farmOS 7

Implements hook_block_view_alter().

File

themes/farm_theme/template.php, line 435
Farm theme template.php.

Code

function farm_theme_block_view_alter(&$data, $block) {
  if ($block->delta == 'farm_map' && is_array($data['content'])) {

    // Add CSS and JS when farm_map block is displayed.
    $data['content']['#attached'] = array(
      'css' => array(
        drupal_get_path('theme', 'farm_theme') . '/css/map_header.css',
      ),
      'js' => array(
        drupal_get_path('theme', 'farm_theme') . '/js/map_header.js',
      ),
    );

    // If the block is being displayed on the homepage, show the farm_areas map.
    // Only allow access with the 'access farm dashboard' permission.
    if (drupal_is_front_page()) {
      $data['content']['#map_name'] = 'farm_areas';
      $data['content']['#access'] = user_access('access farm dashboard');
    }
    elseif (strpos(current_path(), 'farm/assets/') === 0) {
      $data['content']['#map_name'] = 'farm_assets';
      $data['content']['#access'] = user_access('view farm assets');
    }
  }
}