- Patch #569362 by scor, effulgentsia, catch: add attributes and title_attributes() variables for tpl files so that RDFa and Microformats can be implemented.
parent
4f3e5cd940
commit
2729f1c2f0
includes
modules
block
field
node
themes/garland
|
@ -2042,6 +2042,10 @@ function template_preprocess(&$variables, $hook) {
|
|||
// Initialize html class attribute for the current hook.
|
||||
$variables['classes_array'] = array($hook);
|
||||
|
||||
// Initialize attributes for the top-level template entity and its title.
|
||||
$variables['attributes_array'] = array();
|
||||
$variables['title_attributes_array'] = array();
|
||||
|
||||
// Set default variables that depend on the database.
|
||||
$variables['is_admin'] = FALSE;
|
||||
$variables['is_front'] = FALSE;
|
||||
|
@ -2066,6 +2070,10 @@ function template_preprocess(&$variables, $hook) {
|
|||
function template_process(&$variables, $hook) {
|
||||
// Flatten out classes.
|
||||
$variables['classes'] = implode(' ', $variables['classes_array']);
|
||||
|
||||
// Flatten out attributes and title_attributes.
|
||||
$variables['attributes'] = drupal_attributes($variables['attributes_array']);
|
||||
$variables['title_attributes'] = drupal_attributes($variables['title_attributes_array']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
* @see template_process()
|
||||
*/
|
||||
?>
|
||||
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>">
|
||||
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
|
||||
<?php if ($block->subject): ?>
|
||||
<h2><?php print $block->subject ?></h2>
|
||||
<h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
|
||||
<?php endif;?>
|
||||
|
||||
<div class="content">
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* @see theme_comment_wrapper()
|
||||
*/
|
||||
?>
|
||||
<div id="comments" class="<?php print $classes; ?>">
|
||||
<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
|
||||
<?php if ($node->type != 'forum'): ?>
|
||||
<h2 class="comments"><?php print t('Comments'); ?></h2>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -44,14 +44,14 @@
|
|||
* @see theme_comment()
|
||||
*/
|
||||
?>
|
||||
<div class="<?php print $classes; ?> clearfix">
|
||||
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
<?php print $picture ?>
|
||||
|
||||
<?php if ($new): ?>
|
||||
<span class="new"><?php print $new ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3><?php print $title ?></h3>
|
||||
<h3<?php print $title_attributes; ?>><?php print $title ?></h3>
|
||||
|
||||
<div class="submitted">
|
||||
<?php
|
||||
|
|
|
@ -756,8 +756,24 @@ function template_preprocess_field(&$variables) {
|
|||
),
|
||||
);
|
||||
$variables = array_merge($variables, $additions);
|
||||
|
||||
// Initialize attributes for each item.
|
||||
foreach ($variables['items'] as $delta => $item) {
|
||||
$variables['item_attributes_array'][$delta] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme process function for field.tpl.php.
|
||||
*
|
||||
* @see field.tpl.php
|
||||
*/
|
||||
function template_process_field(&$variables) {
|
||||
// Flatten out attributes for each item.
|
||||
foreach ($variables['items'] as $delta => $item) {
|
||||
$variables['item_attributes'][$delta] = drupal_attributes($variables['item_attributes_array'][$delta]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @} End of "defgroup field"
|
||||
*/
|
||||
|
|
|
@ -39,13 +39,13 @@
|
|||
*/
|
||||
?>
|
||||
<?php if ($items) : ?>
|
||||
<div class="field <?php print $classes; ?> clearfix">
|
||||
<div class="field <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
<?php if (!$label_hidden) : ?>
|
||||
<div class="field-label"><?php print $label ?>: </div>
|
||||
<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>: </div>
|
||||
<?php endif; ?>
|
||||
<div class="field-items">
|
||||
<?php foreach ($items as $delta => $item) : ?>
|
||||
<div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"><?php print render($item); ?></div>
|
||||
<div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -70,12 +70,12 @@
|
|||
* @see template_process()
|
||||
*/
|
||||
?>
|
||||
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix">
|
||||
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
|
||||
<?php print $user_picture; ?>
|
||||
|
||||
<?php if (!$page): ?>
|
||||
<h2><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
|
||||
<h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($display_submitted || !empty($content['links']['terms'])): ?>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
// $Id$
|
||||
?>
|
||||
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix">
|
||||
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
|
||||
<?php if (!empty($block->subject)): ?>
|
||||
<h2 class="title"><?php print $block->subject ?></h2>
|
||||
<h2 class="title"<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
|
||||
<?php endif;?>
|
||||
|
||||
<div class="content"><?php print $content ?></div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
// $Id$
|
||||
?>
|
||||
<div class="<?php print $classes . ' ' . $zebra; ?>">
|
||||
<div class="<?php print $classes . ' ' . $zebra; ?>"<?php print $attributes; ?>>
|
||||
|
||||
<div class="clearfix">
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
<?php print $picture ?>
|
||||
|
||||
<h3><?php print $title ?></h3>
|
||||
<h3<?php print $title_attributes; ?>><?php print $title ?></h3>
|
||||
|
||||
<div class="content">
|
||||
<?php hide($content['links']); print render($content); ?>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
// $Id$
|
||||
?>
|
||||
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>">
|
||||
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
|
||||
|
||||
<?php print $user_picture; ?>
|
||||
|
||||
<?php if (!$page): ?>
|
||||
<h2><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
|
||||
<h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($display_submitted): ?>
|
||||
|
|
Loading…
Reference in New Issue