[development] theme_foo() functions vs tpl.php templates (was Move all core modules into their own directories)

Jonathan Chaffer jchaffer at structureinteractive.com
Thu May 4 13:10:52 UTC 2006


On May 4, 2006, at 8:45 AM, Jeremy Epstein wrote:

> Third, the defining of templates and their variables in PHPTemplate
> needs to improve before any of this can happen. Having to define a
> function in your template.php file for every template is already a
> PITA, and it's not what we should be doing when we start putting
> templates in core.

The "intermediary function" in this case is just PHPTemplate's theme  
function implementation. Couldn't we solve this by having the "stub"  
function usually in template.php just *be* the theme_ function? That  
is instead of:

Your module:
   function theme_foo($bar) {
     return '<p> This themes '. $bar .'</p>';
   }

Your theme's template.php:
   function phptemplate_foo($bar) {
       $variables = array(
         'bar' => $bar,
       );
       return _phptemplate_callback('foo', $variables);
   }

you would just have

Your module:
   function theme_foo($bar) {
       $variables = array(
         'bar' => $bar,
       );
       return _phptemplate_callback('foo', $variables);
   }




More information about the development mailing list