Drupal 7 Theming

Im Drupal Theming Guide gibt es eine Übersicht der Änderungen in Drupal 7 und da gibt es eine ganze Reihe von fantastischen Neuerungen. Um nur einige zu nennen:

Blocks have new, more meaningful CSS IDs:

Old CSS ID (Drupal 6): block-user-0
New CSS ID (Drupal 7): block-user-login

HTML classes generated through a variable:
All templates can now print out $classes from a template to render dynamic classes built from variable process functions. The way to add these dynamic classes is by feeding the variable key labeled “classes_array” like so:

<?php
function mytheme_preprocess_node(&$vars) {
 // Add a striping class.
 $vars['classes_array'][] = 'node-' . $vars['zebra'];
}
?>


HTML attributes generated through a variable:

All templates can now print out $attributes, $title_attributes, and $content_attributes from a template to render dynamic attributes built from variable process functions.

<?php
function mytheme_preprocess_node(&$vars) {
 // If the node was saved with a log message and the currently logged in user
 // has permission to view that message, add it as a title attribute (tooltip)
 // when displaying the node.
 if (!empty($vars['node']->log) && user_access('view revisions')) {
 $vars['attributes_array']['title'] = $vars['node']->log;
 }
 // Force the direction of node titles to be left to right, regardless of
 // language or any other settings.
 $vars['title_attributes_array']['dir'] = 'ltr';
}
?>

Granular rendering in node and user templates:

<div class="content">
 <?php
 // We hide the comments and links now so that we can render them later.
 hide($content['comments']);
 hide($content['links']);
 print render($content);
 ?>
</div>
<?php print render($content['links']); ?>
<?php print render($content['comments']); ?>

Possibly related posts (automatically generated)