Explorar o código

Passed $bundle to the template. Added table id.

Chun-Huai Cheng %!s(int64=9) %!d(string=hai) anos
pai
achega
6a86398077

+ 6 - 7
tripal_panes/theme/templates/tripal_panes_generic.tpl.php

@@ -13,7 +13,9 @@ drupal_add_js(drupal_get_path('module','tripal_panes') . '/theme/js/tripal_panes
 // Get the variables passed into this template.
 $panes = $variables['element']['#panes'];
 $fields = $variables['element']['#fields'];
+$bundle = $variables['element']['#bundle'];
 
+$bundle_type = $bundle->name . '-' . $bundle->label;
 
 // Process fields in panes
 $content = '';
@@ -56,7 +58,7 @@ foreach ($panes AS $pane_id => $pane) {
     // The field is not in a table
     else {
       if ($counter != 0 && $current_layout != 'Default') {
-        $output .= tripal_panes_generic_render_table($table_layout);
+        $output .= tripal_panes_generic_render_table($table_layout, $bundle_type);
         $table_layout = array();
       }
       $no_group [$field['#weight'] . $field['#field_name']] = $field;
@@ -65,7 +67,7 @@ foreach ($panes AS $pane_id => $pane) {
     $counter ++;
   }
   if ($current_layout == 'Table') {
-    $output .= tripal_panes_generic_render_table($table_layout);
+    $output .= tripal_panes_generic_render_table($table_layout, $bundle_type);
   }
   else if ($current_layout == 'Default') {
     $output .= tripal_panes_generic_render_fields($no_group);
@@ -90,9 +92,6 @@ foreach ($panes AS $pane_id => $pane) {
   }
 }
 
-// TODO: need to add the bundle type
-$bundle_type = '';
-
 if ($has_base_pane_only) { ?>
   <div id ="tripal-<?php print $bundle_type?>-contents-box"> <?php
     // print the rendered content
@@ -122,7 +121,7 @@ else { ?>
  * @return
  *   A string containing the HTMLified table.
  */
-function tripal_panes_generic_render_table($fields) {
+function tripal_panes_generic_render_table($fields, $bundle_type) {
   // If we have no fields in table layout
   if (count($fields) == 0) {
     return '';
@@ -146,7 +145,7 @@ function tripal_panes_generic_render_table($fields) {
     'header' => $header,
     'rows' => $rows,
     'attributes' => array(
-      'id' => '',  // TODO: need to add an ID
+      'id' => 'tripal_panes-' . $bundle_type . '-table',  // TODO: need to add an ID
       'class' => 'tripal-data-horz-table'
     ),
     'sticky' => FALSE,

+ 1 - 0
tripal_panes/tripal_panes.module

@@ -875,6 +875,7 @@ function tripal_panes_entity_view($entity, $type, $view_mode, $langcode) {
         drupal_add_css(drupal_get_path('module','tripal_panes') . '/theme/css/tripal_panes.css');
         $entity->content['tripal_panes_generic'] = array(
           '#theme' => 'tripal_panes_generic',
+          '#bundle' => $bundle,
           '#panes' => $panes,
           '#fields' => $fields,
         );