2013-02-15 39 views
1

我想提出一個Drupal表,擡頭drupal_theme(),並試圖按照規則,用下面的代碼構建表:Drupal的6臺主題()輸出

$data = array('value', 'values'); 
    $header = array ($data); 
    $rows = array(
    // Simple row 
    array(
     'Cell 1', 'Cell 2', 'Cell 3' 
    ), 
    // Row with attributes on the row and some of its cells. 
    array(
     'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 
     'class' => 'funky' 
    ) 
    ); 

    //$output = theme('table', $header, $rows, $attributes = array(), 
    //$caption = NULL); 
    $table_t = theme_table($header, $rows, $attributes = array(), $caption = NULL); 
    //return $output; 
    return $table_t; 

然而,該表沒有按」 t包含像我期望的行和列標題。怎麼了??

截圖: enter image description here

+0

此外,考慮要求對http://drupal.stackexchange.com – Watki02 2013-02-15 23:01:22

+0

@ Watki02不挑剔,但發佈不允許跨站點,這將會是巨大的如果你可以讓別人知道他們需要舉報移民,如果他們想在另一個網站上提問:) – Clive 2013-02-15 23:12:30

回答

1

我不知道這是否會有所幫助,但是這是我在我的模塊之一使用表頭的代碼。

$header = array(
    array('data' => t('One')), 
    array('data' => t('Two')), 
    array('data' => t('Three')), 
    array('data' => t('Four')), 
); 

看看是否適合你。

此外,theme_table($header, $rows, $attributes = array(), $caption = NULL)可以只是theme_table($header, $rows)

+0

你在這兩個賬戶上都是對的。在用你的代碼替換$ header之後,會列出一列,兩列,三列和四列。也不需要屬性和標題。至於行標題,我想知道你知道嗎?謝謝:) – ingrid 2013-02-15 23:12:14

+0

我能想到的最好的事情是將第1列中的fow值賦值爲行標籤,所以array('data'=> array('row1','value','value'),'data '=> array('row2','value','value')); etc .. – ingrid 2013-02-15 23:28:26

+1

我不認爲表主題功能支持任何行標題(也許行標記是一個更好的術語)。我能想到的最好的做法是製作第一列空白標題,然後給每一行中的第一個單元格提供一個類,然後提供自己的樣式,或者將類設置爲與標題單元格相同。如果有必要的話,只要玩一下它就可以問另一個問題,這樣你就可以看到更多的眼球。 – shanet 2013-02-15 23:59:51