Following line should be added to comment.tpl.php.

$zebra: Outputs either "even" or "odd". Useful for zebra striping.

Comments

Jarek Foksa’s picture

Title: Documentation problem with comment.tpl.php » Add $zebra to the list of comment.tpl.php variables
Version: 6.x-dev » 7.x-dev
jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

Hmmm... I don't see that in template_preprocess_comment anywhere. Can you point to where that variable is being defined?

Jarek Foksa’s picture

Status: Postponed (maintainer needs more info) » Active

The 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.

jhodgdon’s picture

Ah.

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).

jhodgdon’s picture

It 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?

Jarek Foksa’s picture

I 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".

/**
 * @file
 * Default theme implementation to display a single Drupal page.
 *
 * Available variables:
 
 * Global variables (accessible from all template files)
 * - $is_admin: TRUE if the user has permission to access administration pages.
 * - $is_front: TRUE if the current page is the front page.
 * - $logged_in: TRUE if the user is registered and signed in.
 * - $directory: The directory the template is located in, e.g. modules/system
 *   or themes/garland.
 * - $zebra: Outputs either "even" or "odd". Useful for zebra striping.
 * - $id: Counter, returns number for every node/comment/block/etc.
*
 * Paths:
 * - $base_path: The base URL path of the Drupal installation. At the very
 *   least, this will always default to /.
 * - $front_page: The URL of the front page. Use this instead of $base_path,
 *   when linking to the front page. This includes the language domain or
 *   prefix.
 *
 * Navigation:
 * - $main_menu (array): An array containing the Main menu links for the
 *   site, if they have been configured.
 * - $secondary_menu (array): An array containing the Secondary menu links for
 *   the site, if they have been configured.
 * - $breadcrumb: The breadcrumb trail for the current page.
 *
 * Page content (in order of occurrence in the default page.tpl.php):
 * - $logo: The path to the logo image, as defined in theme configuration.
 * - $site_name: The name of the site, empty when display has been disabled
 *   in theme settings.
 * - $site_slogan: The slogan of the site, empty when display has been disabled
 *   in theme settings.
 * - $title_prefix (array): An array containing additional output populated by
 *   modules, intended to be displayed in front of the main title tag that
 *   appears in the template.
 * - $title: The page title, for use in the actual HTML content.
 * - $title_suffix (array): An array containing additional output populated by
 *   modules, intended to be displayed after the main title tag that appears in
 *   the template.
 * - $messages: HTML for status and error messages. Should be displayed
 *   prominently.
 * - $tabs (array): Tabs linking to any sub-pages beneath the current page
 *   (e.g., the view and edit tabs when displaying a node).
 * - $action_links (array): Actions local to the page, such as 'Add menu' on the
 *   menu administration interface.
 * - $feed_icons: A string of all feed icons for the current page.
 * - $node: The node object, if there is an automatically-loaded node
 *   associated with the page, and the node ID is the second argument
 *   in the page's path (e.g. node/12345 and node/12345/revisions, but not
 *   comment/reply/12345).
 *
 * Regions:
 * - $page['help']: Dynamic help text, mostly for admin pages.
 * - $page['highlight']: Items for the highlighted content region.
 * - $page['content']: The main content of the current page.
 * - $page['sidebar_first']: Items for the first sidebar.
 * - $page['sidebar_second']: Items for the second sidebar.
 * - $page['header']: Items for the header region.
 * - $page['footer']: Items for the footer region.
 *
 * @see template_preprocess()
 * @see template_preprocess_page()
 * @see template_process()
 */
jhodgdon’s picture

I 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.

?

Jarek Foksa’s picture

Title: Add $zebra to the list of comment.tpl.php variables » Global variables should be listed only in one place instead of repeating them in every template file
Priority: Minor » Normal
Jarek Foksa’s picture

Looks 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.

jhodgdon’s picture

Title: Global variables should be listed only in one place instead of repeating them in every template file » Global variables for theme templates should be listed somewhere

New 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.