From 06bc4a24bc0ecf9901d486500cf1bf3e0a55ae20 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Wed, 13 Jun 2018 12:59:15 -0400 Subject: [PATCH] Add asset, log, and plan types to entity view pages so it's clear what you're looking at. --- modules/farm/farm_asset/farm_asset.module | 9 +++++++++ modules/farm/farm_log/farm_log.module | 20 ++++++++++++++++++++ modules/farm/farm_plan/farm_plan.module | 9 +++++++++ 3 files changed, 38 insertions(+) diff --git a/modules/farm/farm_asset/farm_asset.module b/modules/farm/farm_asset/farm_asset.module index 674494ec..df9fa411 100644 --- a/modules/farm/farm_asset/farm_asset.module +++ b/modules/farm/farm_asset/farm_asset.module @@ -324,6 +324,15 @@ function farm_asset_entity_view($entity, $type, $view_mode, $langcode) { return; } + // Add the asset type. + $asset_types = farm_asset_type_get_names(); + if (!empty($asset_types[$entity->type])) { + $entity->content['type'] = array( + '#markup' => '
Asset type: ' . $asset_types[$entity->type] . '
', + '#weight' => -101, + ); + } + // If the asset is archived, display a message and the archived date. if (!empty($entity->archived)) { drupal_set_message(t('This asset is archived. Archived assets should not be edited or deleted unless they contain information that is incorrect.'), 'warning'); diff --git a/modules/farm/farm_log/farm_log.module b/modules/farm/farm_log/farm_log.module index 4df55e40..de3c6117 100644 --- a/modules/farm/farm_log/farm_log.module +++ b/modules/farm/farm_log/farm_log.module @@ -7,6 +7,26 @@ // Include Features code. include_once 'farm_log.features.inc'; +/** + * Implements hook_entity_view(). + */ +function farm_log_entity_view($entity, $type, $view_mode, $langcode) { + + // If the entity is not a log, bail. + if ($type != 'log') { + return; + } + + // Add the log type. + $log_types = log_type_get_names(); + if (!empty($log_types[$entity->type])) { + $entity->content['type'] = array( + '#markup' => '
Log type: ' . $log_types[$entity->type] . '
', + '#weight' => -101, + ); + } +} + /** * Implements hook_form_alter(). */ diff --git a/modules/farm/farm_plan/farm_plan.module b/modules/farm/farm_plan/farm_plan.module index 8db728ed..d8af7124 100644 --- a/modules/farm/farm_plan/farm_plan.module +++ b/modules/farm/farm_plan/farm_plan.module @@ -302,6 +302,15 @@ function farm_plan_entity_view($entity, $type, $view_mode, $langcode) { return; } + // Add the plan type. + $plan_types = farm_plan_type_get_names(); + if (!empty($plan_types[$entity->type])) { + $entity->content['type'] = array( + '#markup' => '
Plan type: ' . $plan_types[$entity->type] . '
', + '#weight' => -101, + ); + } + // Add the plan's "active" status. if ($entity->active) { $status = 'Yes';