[support] Templating in Drupal 5.1 - the cleanest way to do it?

Larry Garfield larry at garfieldtech.com
Wed Apr 11 02:47:44 UTC 2007


Drat.  I knew I'd forget something. :-)

The important part is that phptemplate_themekey() takes the same parameters as 
the theme_ function it's overriding, but _phptemplate_callback() takes a 
named array of values that turn into variables in the template file itself.

On Tuesday 10 April 2007 4:04 pm, Cyberswat wrote:
> The threads probably getting old ... but just in case anyone else is
> following this, Larry's example is almost perfect. Simply modify
>
> function phptemplate_foo_or_something() {
>
> to
>
> function phptemplate_foo_or_something($data) {
>
> Then everything will work. Thanks for the help David and Larry.
>
> On 4/10/07, Larry Garfield <larry at garfieldtech.com> wrote:
> > #################################################
> > module code - mymod.php
> > #################################################
> >
> > function mymod_foo() {
> >   $data = array('foo' => 'bar');
> >   return theme('foo_or_something', $data);
> > }
> >
> > function theme_foo_or_someting($data) {
> >   return "something you do with $data that generates a string";
> > }
> >
> > #################################################
> > template.php code
> > #################################################
> >
> > function phptemplate_foo_or_something() {
> >   return _phptemplate_callback('foo_or_something', $data);
> > }
> >
> >
> > #################################################
> > foo_or_something.tpl.php
> > #################################################
> >
> > <h1>I want to output value of $foo here</h1>
> >
> > (In this case $foo will have a value of 'bar').
> >
> > Cheers.
> >
> > --Larry Garfield

-- 
Larry Garfield			AIM: LOLG42
larry at garfieldtech.com		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson


More information about the support mailing list