소스 검색

Still working on paging

Stephen Ficklin 7 년 전
부모
커밋
9d212cc391

+ 8 - 0
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship.inc

@@ -41,6 +41,7 @@ class sbo__relationship extends ChadoField {
       'option2_parent' => '',
       'relationship_types' => '',
     ),
+    'items_per_page' => 10,
   );
 
   // The default widget for this field.
@@ -519,6 +520,13 @@ class sbo__relationship extends ChadoField {
   public function settingsForm($has_data) {
     $element = parent::instanceSettingsForm();
 
+    $element['items_per_page'] = array(
+      '#type' => 'textfield',
+      '#title' => 'Items per Page',
+      '#description' => t('The number of items that should appear on each page.  A pager is provided if more than this number of items exist.'),
+      '#default_value' => $this->instance['settings']['items_per_page'],
+    );
+
     //$element = parent::instanceSettingsForm();
     $element['relationships'] = array(
       '#type' => 'fieldset',

+ 1 - 1
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship_formatter.inc

@@ -101,7 +101,7 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
     }
 
     // Build the pager
-    $items_per_page = 25;
+    $items_per_page = array_key_exists('items_per_page', $this->instance['settings']) ? $this->instance['settings']['items_per_page'] : 10;
     $total_records = count($items);
     $total_pages = (int) ($total_records / $items_per_page) + 1;
     $pelement = 0; //$this->getPagerElementID();