Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Following line should be added to comment.tpl.php.
$zebra: Outputs either "even" or "odd". Useful for zebra striping.
Comments
Comment #1
Jarek Foksa CreditAttribution: Jarek Foksa commentedComment #2
jhodgdonHmmm... I don't see that in template_preprocess_comment anywhere. Can you point to where that variable is being defined?
Comment #3
Jarek Foksa CreditAttribution: Jarek Foksa commentedThe variable is defined in template_preprocess() and it's already documented in node.tpl.php and block.tpl.php. Zebra stripping is often used for comments, it would make sense to add it to comment.tpl.php too.
Comment #4
jhodgdonAh.
Well, template_preprocess adds other variables too:
$id
$directory
$classes_array
Plus all the ones from
http://api.drupal.org/api/function/_template_preprocess_default_variables/7
Do you think we should add all of these?
I agree that $zebra is a good one. $id seems almost as important (it gives a running ID number to each comment, to go with the zebra striping).
Comment #5
jhodgdonIt seems like a good approach here for the default variables would be to document all of them somewhere and refer all the other template files to that documentation, rather than trying to get all the default variables documented in each template function.
Thoughts?
Comment #6
Jarek Foksa CreditAttribution: Jarek Foksa commentedI like the idea, page.tpl.php seems to be the best place for listing all global variables. Below is my proposal for updated page.tpl.php. Global variables should be removed from other template files and replaced with following line: "Check page.tpl.php for list of available global variables".
Comment #7
jhodgdonI don't really agree that page.tpl.php is a good central reference for common variables. page.tpl.php is pretty big...
Maybe instead we should document them on template_preprocess() itself, and put a standard message in all .tpl.php files in the variables section:
See template_preprocess() for a list of standard variables accessible from all templates.
?
Comment #8
Jarek Foksa CreditAttribution: Jarek Foksa commentedComment #9
Jarek Foksa CreditAttribution: Jarek Foksa commentedLooks fine to me, though I'm not really sure whether all themers will understand this message - when I was starting with Drupal I had no idea what "preprocess function" is and where to look for it.
Comment #10
jhodgdonNew suggested wording:
See template_preprocess() for a list of additional variables accessible from all templates.
And we would need to document them in template_preprocess() too.