1

I am using following code for theming..

theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => 'view-all-frame')));

is the above format right? Can 'attributes' be written above inside array? Can I use theme_table() instead of theme()?

theme_table(array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => 'view-all-frame')));

If they are same then does it affect the execution or anything related to it?

Similarly for theme('item_list', array()) and theme_item_list();

0
5

It's not the same.

theme() function is some kind of wrapper for specified theme functions.

It's recommended to use theme() function instead of direct calls, so theme('item_list', array()) is the right way.

5
  • is theme() format right ? Can attributes be used inside an array as i read that attributes is an reserved word or we can use attributes – harshal Aug 13 '13 at 10:07
  • What do you mean? – deem Aug 13 '13 at 10:09
  • is the above written theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => 'view-all-frame'))) correct ?; – harshal Aug 13 '13 at 10:11
  • 2
    It will work, but the most proper code is theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('view-all-frame')))); – deem Aug 13 '13 at 10:18
  • can it simpler like that theme('table', array($header, $rows, array('class' => array('view-all-frame'))); – Stone Vo Aug 13 '13 at 10:24
-1

I think the function of theme_table and theme('table',array()) is the same. But the way you call the theme_table should be simple like that:

theme_table($header,$rows,array('class' => 'view-all-frame'));
2
  • 1
    No, theme_table() and theme('table', array()) are not the same: The first calls a function, and the other one calls another function. Does theme('table') call theme_table()? It all depends from the presence of a module that set another theme function as "table" theme function. – kiamlaluno Aug 14 '13 at 16:36
  • 1
    @kiamlaluno Thank you a lot. It'll help me understand more about the theme engine in Drupal. – Stone Vo Aug 14 '13 at 16:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.