theming
background images
Submitted by Mark Yuasa on Thu, 16/11/2006 - 3:21pm. drupal | themingcreating a comment.tpl.php file
drupal | comment.tpl.php | template | themingcomment.tpl.php default code
<div class="comment <?php print ($comment->new) ? 'comment-new' : '' ?>">
<?php if ($comment->new) : ?>comment.tpl.php Variables
drupal | comment.tpl.php | theming | variablesYou can use the variables on this page to print out dynamic content in your comment.tpl.php document.
The following list and descriptions are from Drupal.org
View the PHP syntax used to apply these variable to your *.tpl.php file.
Available variables
- $new
- Translated text for 'new', if the comment is infact new.
- $comment(object)
- Comment object as passed to the theme_comment function.
comment.tpl.php Overview
drupal | comment.tpl.php | themingcomment.tpl.php Basics
This is the template file for comment. Comments are optional pieces of content that can be attached to certain nodes or node types. You can specify which node-types should allow comments within the Drupal administrative area.
theme_comment function
The theme_comment function is like theme_page and theme_node. The theme_comment function returns a themed comment. The function contains the mark-up that is generated by default.
function theme_comment($comment, $links = array()) {
$output = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">';creating a block.tpl.php file
drupal | block.tpl.php | themingblock.tpl.php default code
<div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
<h2><?php print $block->subject ?></h2>block.tpl.php Variables
drupal | block.tpl.php | theming | variablesYou can use the variables on this page to print out dynamic content in your block.tpl.php document.
The following list and descriptions are from Drupal.org
View the PHP syntax used to apply these variable to your *.tpl.php file.
Available variables
- $block (object)
- $block->module
- The name of the module that generated the block.
block.tpl.php Overview
drupal | block.tpl.php | themingblock.tpl.php Basics
This is the template file for blocks. Blocks are small containers for content that are placed throughout a drupal layout, where ever there are block regions.
Before Drupal 4.7, blocks could only show in the left and/or right sidebars. Most themes have four or five regions:
- header
- left
- right
- footer
theme_block function
The theme_block function is like theme_page and theme_node. The theme_block function returns a themed block. The function contains the mark-up that is generated by default. This code is very short and easy to read:
creating a node.tpl.php file
drupal | node.tpl.php | template | themingnode.tpl.php in box_grey
We looked at page.tpl.php in box_grey which is a great, simple theme. It does have some limitations though:
- Tables are still used for visual Layout
- Structural tags are used strictly for clearing: <br class="clear" />
- Some static title and alt values are explicitly set
The default node.tpl.php mark-up on the other hand is quite usable. It's not nearly as complex as far as structure goes because it does not require any mark-up for layout. It is just the content after all:
node.tpl.php Variables
drupal | node.tpl.php | theming | variablesYou can use the variables on this page to print out dynamic content in your node.tpl.php document.
The following list and descriptions are from Drupal.org
View the PHP syntax used to apply these variable to your *.tpl.php file.
- $title
- Title of node.
- $node_url
- Link to node.
- $terms
- HTML for taxonomy terms.
node.tpl.php Overview
drupal | node.tpl.php | template | themingHere's the official word from Drupal.org on node.tpl.php:
This template controls the display of a node, and a node summary.
View the Overview of node.tpl.php at Drupal.org
Node?
No really, what is a node? A node is an individual piece of content, so a blog post, a book page, a forum entry and an original

Recent comments