PHP Template Functions in Module in Drupal
PHPTemplate is a theme engine which utilizes *.tpl.php files to theme Drupal's theme_*(functions). The theme files include an HTML skeleton with PHP statements for dynamic content. Therefore, PHPTemplate is a useful tool for theming if you are comfortable coding with PHP. Using PHPTemplate, you can create advanced themes easily via some basic PHP snippets. Drupal's themeable functions can display HTML and can be customized by themes.
-
Themeable Functions
-
All functions producing HTML for display are themeable. They are named with the theme_prefix and invoked using theme () rather than being called directly. These functions enable themes to override the display of Drupal objects. The theme system is specified in a theme system "theme.inc."
Theme_block () Function
-
This function returns a themed block. Its parameter "$block" is an object populated with fields from the "blocks" database table. Using this function, you can style your blocks by defining blocks in your theme's CSS.
-
Theme_box () Function
-
This function has four parameters: $title, $content, $region. $title is the subject of the box, $content is the content of the box, while $region represents the region where the box is shown. It returns a themed box.
Theme_image () Function
-
The theme_image function returns a themed image. Its parameters consist of the followings: $path (either the path of the image file or a complete URL); $alt (the alternative text for the image); $title (the title text is shown when the image is hovered); $attributes (relative array of attributes to be put in the image tag); and $getsize: (the image's dimensions are caught and added as width/height attributes).
-
References
- Photo Credit Hemera Technologies/Photos.com/Getty Images