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.
This should help me theme. What are your thoughts?
I was able to do this in template.php.
function sitetheme_preprocess_page(&$variables) {
$nodes = $variables['page']['content']['system_main']['nodes'];
$i = 1;
$len = count($nodes);
foreach (array_keys($nodes) as $nid) {
if ($i == 1) {
$nodes[$nid]['#node']->classes_array = array('first');
}
elseif ($i == $len - 1) {
$nodes[$nid]['#node']->classes_array = array('last');
}
else {
$nodes[$nid]['#node']->classes_array = array('');
}
/* So I don't get "Warning: Cannot use a scalar value as an array" */
unset($nodes,$nid);
$i++;
}
}
function sitetheme_preprocess_node(&$variables) {
$node = $variables['node'];
if (!empty($node->classes_array)) {
$variables['classes_array'] = array_merge($variables['classes_array'], $node->classes_array);
}
}
Comment | File | Size | Author |
---|---|---|---|
#4 | zen_add_teaser_classes.patch | 1.58 KB | n8tron |
Comments
Comment #1
n8tronWell, maybe this is better.
Comment #2
n8tronOk -- check this out. This should help front end folks get the classes they need. Thoughts?
template.php
Comment #3
JohnAlbinpatch, please?
Comment #4
n8tronSure John! Patch provided.
Comment #5
JohnAlbinBah. I just realized this code assumes that the main content block is in the content region.
Maybe you have to attack it from the main content block itself?
Comment #6
thissideup CreditAttribution: thissideup commentedthanks, that helped me a lot!
Comment #7
thissideup CreditAttribution: thissideup commented...I really don't know, why it changed that.. :(
Comment #8
jim005 CreditAttribution: jim005 commentedThanks ! Perfect for us. Drupal 7, Zen 7.5.
Comment #9
JohnAlbinclosing.