What Functions Are Available In A Drupal PHPTemplate Theme?

Sponsored Links

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

  • All spam and irrelevant comments will be deleted.
  • Comments posted here will take some time to appear on the site. Do not post your comment again if you do not see it. Just be patient and it will be published.
  • Note that what you post here will be publicly available on the web and will be indexed in search engines.
  • We reserve the right to unpublish any comments without stating the reasons for that.
  • All postings are subject to our Terms of use
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