Skip to main content

Posts

Showing posts from December, 2013

theme(INSTANCE, $var) VS theme_INSTANCE($var)

The following is most common for functions like theme('table', $var) that are included by default in Drupal core instead of calling straight theme_table($var). Since theme_table is stored in includes/theme.inc file it is always available. It might be stored in a file not always loaded though. In that case theme('table', $var) would be our only way. What's the difference though?
If we check the theme_table() function (@see https://api.drupal.org/api/drupal/includes!theme.inc/function/theme_table/7) we will read the following lines: $header = $variables['header'];
$rows = $variables['rows'];
$attributes = $variables['attributes'];
$caption = $variables['caption'];
$colgroups = $variables['colgroups'];
$sticky = $variables['sticky'];
$empty = $variables['empty'];

This requires the header, rows, attributes, capton, colgroups, sticky and empty keys to exist even with no content. If a key is not found, an error is wri…