views:

62

answers:

1

Hi everyone,

How would I go around overriding a theme function with a .tpl file? I know how to override a .tpl file with a theme function but not the other way round. I can't seem to find anywhere that tells me so, so maybe it's not possible or not good practice.

For example if there was a theme function defined in a module called super_results and registered with the theme registry, like the example below, how would I go around overriding it with super_results.tpl.php.

'super_results' => array(
      'arguments' => array('title' => NULL, 'results' => NULL, 'votes' => NULL),
    ),

function modulename_super_results($title, $results,$votes){ output HTML }
+1  A: 

The simplest solution would probably be creating a new theming function that uses a template. Something like that should work, disclaimer code is untested.

function my_theme_theme() {
  return array(
    'overide' => array(
      'template' => 'elm-super_results',
      'arguments' => array('title' => NULL, 'results' => NULL, 'votes' => NULL),
    ),
  );
}

function my_theme_super_results($title, $results, $votes) {
  return theme('overide', $title, $results, $votes);
}
googletorp
That's bloody clever. Thanks Googletorp:)
Nick Lowman

related questions