array( 'title' => t('Add a crop'), 'href' => 'admin/structure/taxonomy/farm_crops/add', 'paths' => array( 'farm/plantings', 'farm/plantings/crops', ), ), 'harvest' => array( 'title' => t('Add a harvest'), 'href' => 'log/add/farm_harvest', 'assets' => array( 'planting', ), 'views' => array( 'farm_log_harvest', ), ), 'input' => array( 'title' => t('Add an input'), 'href' => 'log/add/farm_input', 'assets' => array( 'planting', ), 'views' => array( 'farm_log_input', ), 'paths' => array( 'taxonomy/term/%', ), ), 'planting' => array( 'title' => t('Add a planting'), 'href' => 'farm/asset/add/planting', 'views' => array( 'farm_plantings', ), 'paths' => array( 'farm/plantings', ), ), 'seeding' => array( 'title' => t('Add a seeding'), 'href' => 'log/add/farm_seeding', 'assets' => array( 'planting', ), 'views' => array( 'farm_log_seeding', ), ), 'transplanting' => array( 'title' => t('Add a transplanting'), 'href' => 'log/add/farm_transplanting', 'assets' => array( 'planting', ), 'views' => array( 'farm_log_transplanting', ), ), ); return $actions; } /** * Implements hook_farm_asset_view_views(). */ function farm_crop_farm_asset_view_views($farm_asset) { // If the entity is not a planting, bail. if ($farm_asset->type != 'planting') { return array(); } // Return a list of Views to include on Plantings. return array( 'farm_log_seeding', 'farm_log_transplanting', 'farm_log_input', 'farm_log_harvest', 'farm_log_activity', 'farm_log_observation', 'farm_log_movement', ); } /** * Implements hook_farm_taxonomy_term_view_views(). */ function farm_crop_farm_taxonomy_term_view_views($term) { // Start a list of View names. $views = array(); // Switch logic depending on the vocabulary. switch ($term->vocabulary_machine_name) { // Farm areas: case 'farm_areas': $views[] = array( 'name' => 'farm_plantings', 'arg' => 1, 'weight' => -20, ); $views[] = array( 'name' => 'farm_log_input', 'arg' => 2, ); break; // Farm crops. case 'farm_crops': $views[] = array( 'name' => 'farm_plantings', 'arg' => 2, ); break; // Farm crop family. case 'farm_crop_families': $views[] = 'farm_crops'; break; } return $views; } /** * Implements hook_form_alter(). */ function farm_crop_form_alter(&$form, &$form_state, $form_id) { // If this is a log form with a planting reference field... if ($form_id == 'log_form' && !empty($form['field_farm_planting'])) { // Alter the form with the farm_log helper function. farm_log_form_prepopulate_asset($form, 'field_farm_planting'); } } /** * Implements hook_farm_area_links(). */ function farm_crop_farm_area_links($id) { return array( array( 'title' => t('Inputs'), 'href' => 'taxonomy/term/' . $id, 'options' => array( 'fragment' => 'Inputs', ), 'weight' => 10, ), array( 'title' => t('Plantings'), 'href' => 'taxonomy/term/' . $id, 'options' => array( 'fragment' => 'Plantings', ), ), ); }