diff options
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/node.module | 19 | ||||
-rw-r--r-- | modules/node/node.tpl.php | 18 |
2 files changed, 36 insertions, 1 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index 6504aa78f..c190d2609 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1387,6 +1387,25 @@ function template_preprocess_node(&$variables) { $variables['submitted'] = ''; $variables['picture'] = ''; } + + // Gather node classes. + $variables['classes_array'][] = 'node-' . $node->type; + if ($variables['promote']) { + $variables['classes_array'][] = 'node-promoted'; + } + if ($variables['sticky']) { + $variables['classes_array'][] = 'node-sticky'; + } + if (!$variables['status']) { + $variables['classes_array'][] = 'node-unpublished'; + } + if ($variables['teaser']) { + $variables['classes_array'][] = 'node-teaser'; + } + if (isset($variables['preview'])) { + $variables['classes_array'][] = 'node-preview'; + } + // Clean up name so there are no underscores. $variables['template_files'][] = 'node-' . str_replace('_', '-', $node->type); $variables['template_files'][] = 'node-' . $node->nid; diff --git a/modules/node/node.tpl.php b/modules/node/node.tpl.php index d2c7ec4df..92e6c128e 100644 --- a/modules/node/node.tpl.php +++ b/modules/node/node.tpl.php @@ -20,6 +20,19 @@ * - $terms: the themed list of taxonomy term links output from theme_links(). * - $submitted: themed submission information output from * theme_node_submitted(). + * - $classes: String of classes that can be used to style contextually through + * CSS. It can be manipulated through the variable $classes_array from + * preprocess functions. The default values can be one or more of the following: + * - node: The current template type, i.e., "theming hook". + * - node-[type]: The current node type. For example, if the node is a + * "Blog entry" it would result in "node-blog". Note that the machine + * name will often be in a short form of the human readable label. + * - node-teaser: Nodes in teaser form. + * - node-preview: Nodes in preview mode. + * The following are controlled through the node publishing options. + * - node-promoted: Nodes promoted to the front page. + * - node-sticky: Nodes ordered above other non-sticky nodes in teaser listings. + * - node-unpublished: Unpublished nodes visible only to administrators. * TODO D7 : document $FIELD_NAME_rendered variables. * * Other variables: @@ -28,6 +41,8 @@ * - $comment_count: Number of comments attached to the node. * - $uid: User ID of the node author. * - $created: Time the node was published formatted in Unix timestamp. + * - $classes_array: Array of html class attribute values. It is flattened + * into a string within the variable $classes. * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in * teaser listings. * - $id: Position of the node. Increments each time it's output. @@ -47,9 +62,10 @@ * * @see template_preprocess() * @see template_preprocess_node() + * @see template_process() */ ?> -<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clearfix"> +<div id="node-<?php print $node->nid; ?>" class="<?php print $classes ?> clearfix"> <?php print $picture ?> |