[themes] Example phptemplate theme

Darrel O'Pry dopry at thing.net
Tue Dec 6 04:19:58 UTC 2005


On Mon, 2005-12-05 at 15:29 -0800, Tao Starbow wrote:
> Darrel O'Pry wrote:
> 
> >On Mon, 2005-12-05 at 16:03 -0500, Rowan Kerr wrote:
> >  
> >
> >>On 12/5/05, Tao Starbow <starbow at citris-uc.org> wrote:
> >>    
> >>
> >>>Is there a documentation page somewhere that lists/describes all the
> >>>methods of $node that can be accessed in a template?
> >>>      
> >>>
> >>http://drupal.org/phptemplate and http://drupal.org/node/11816
> >>
> >>Basically, the entire node object is available from a node's
> >>phptemplate file, but I'm not sure how many of drupal's functions are.
> >>    
> >>
> >
> >Most everything is there.. Objects in drupal pretty much only use
> >properties, so you won't be finding any node methods....
> >
> >You can try a '<pre>' . print_r($node, true). '</pre>' to see what all
> >is in the node.
> >
> >If you want to see all the function availble from within php template
> >you can try some of php's introspection functions.
> >....
> >
> ><ul> 
> ><?php
> >$functions = get_defined_functions();
> >foreach($functions['user'] as $function) { 
> >?>
> >	<li>$function</li>
> ><?php
> >}
> >?>
> ></ul>
> >
> >...
> >
> >you can also use get_defined_vars and get_defined_constants, etc...
> >  
> >
> Thanks, that a great way to find the stuff left off the documentation at 
> node/11816.
> I had to fiddle just a bit with your examples to get them to work from 
> inside a sample node.tpl.php file
> 
> <!-- All node properties -->
> <pre>
>   <?php print_r($node, false) ?>
> </pre>
> 
> <!-- The Drupal API as seen from the template -->
> <ul>
> <?php
> $functions = get_defined_functions();
> foreach($functions['user'] as $function) {
> ?>
>     <li><?php print $function ?></li>
> <?php
> }
> ?>
> </ul>

Should of mentioned I just typed that up on the top of my head... I
found its useful code to know for working on any foreign project or
templating system... 

one caveat with that though, you don't get full function definitions and
it might not be wise to grab any function and use it unless you verify
with a developer you are using it in an appropriate way. Not all
functions are atomic :)...







More information about the themes mailing list