What Functions Are Available In A Drupal PHPTemplate Theme?

What Functions Are Available In A Drupal PHPTemplate Theme?

Darrel O'Pry posted this gem on the Drupal Themes mailing list, and it deserves to be publicized.

Paste this in your page.tpl.php below the <body> tag, to see what functions are available for you, the theme developer.

  <ul>
<?php
$functions = get_defined_functions();
foreach($functions['user'] as $function) :
print "<li>$function</li>";
endforeach;
?>
</ul>

Similarly, one can use the get_defined_vars() and get_defined_constants() to see what variables are available.

Now, use your imagination and build nice themes ...

List all themeable functions

If you only want to list all themeable functions available try this:

    < ? php
    $functions = get_defined_functions();
    foreach($functions['user'] as $function):
    if (strpos($function,'theme_') === 0):
    print "
  • $function
  • ";
    endif;
    endforeach;
    ? >

Module?

This code would make a handy module

Hey, it works in a node!

I've posted this code in a node for that on-the-go sort of reference.
List of themeable functions for Drupal 4.6.x"

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.

More information about formatting options