Browse Source

Some example code for panes

Stephen Ficklin 9 years ago
parent
commit
32caa38492

+ 27 - 27
legacy/tripal_organism/tripal_organism.install

@@ -43,33 +43,33 @@ function tripal_organism_install() {
  */
 function tripal_organism_schema() {
  $schema['chado_organism'] = array(
-      'fields' => array(
-         'vid' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'not null' => TRUE,
-            'default' => 0
-          ),
-         'nid' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'not null' => TRUE,
-            'default' => 0
-          ),
-         'organism_id' => array(
-            'type' => 'int',
-            'not null' => TRUE,
-            'default' => 0
-          )
-      ),
-      'indexes' => array(
-         'organism_id' => array('organism_id')
-      ),
-      'unique keys' => array(
-         'nid_vid' => array('nid', 'vid'),
-         'vid' => array('vid')
-      ),
-      'primary key' => array('nid'),
+    'fields' => array(
+       'vid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'default' => 0
+        ),
+       'nid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'default' => 0
+        ),
+       'organism_id' => array(
+          'type' => 'int',
+          'not null' => TRUE,
+          'default' => 0
+        )
+    ),
+    'indexes' => array(
+       'organism_id' => array('organism_id')
+    ),
+    'unique keys' => array(
+       'nid_vid' => array('nid', 'vid'),
+       'vid' => array('vid')
+    ),
+    'primary key' => array('nid'),
   );
   return $schema;
 }

+ 43 - 0
tripal_chado/includes/fields/organism_id.inc

@@ -72,4 +72,47 @@ function tripal_chado_organism_select_widget_validate($element, &$form_state) {
   }
 }
 
+function organism_id_field_formatter_settings_summary($field, $instance, $view_mode) {
+  $display = $instance['display'][$view_mode];
+  $settings = $display['settings'];
+  dpm('yo');
+
+  $summary = '';
+
+  if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
+    $summary = t('Length: @chars chars', array('@chars' => $settings['trim_length']));
+  }
+
+  return $summary;
+}
+/**
+ * Implements hook_field_formatter_settings_form()
+ *
+ * @param $field
+ * @param $instance
+ * @param $view_mode
+ * @param $form
+ * @param $form_state
+ */
+function organism_id_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
+  $display = $instance['display'][$view_mode];
+  $settings = $display['settings'];
+  dpm('hi');
+  $element = array();
+
+  if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
+    $element['trim_length'] = array(
+      '#title' => t('Length'),
+      '#type' => 'textfield',
+      '#size' => 20,
+      '#default_value' => $settings['trim_length'],
+      '#element_validate' => array('element_validate_integer_positive'),
+      '#required' => TRUE,
+    );
+  }
+
+  return $element;
+
+}
+
 

+ 1 - 0
tripal_chado/tripal_chado.module

@@ -615,6 +615,7 @@ function tripal_chado_field_widget_form_alter(&$element, &$form_state, $context)
   }
 }
 
+
 /**
  * Implements hook_field_formatter_view().
  */

+ 1 - 1
tripal_panes/theme/templates/tripal_panes_generic.tpl.php

@@ -138,7 +138,7 @@ function tripal_panes_generic_render_table($fields) {
         'width' => '20%',
         'nowrap' => 'nowrap'
       ),
-      $field[0]['#markup']
+      '<span class="field field-name-' . preg_replace('/_/', '-', $field['#field_name']) . '">' . $field[0]['#markup'] . '</span>'
     );
   }
   // Theme the table.