交互的摘要页style class
该文章通过修改主题node.tpl.php文件,到达在摘要列表页为node指定不同的样式风格。
主要增加了:
<?php global $node_count; print ($node_count++ % 2) ? 'odd' : 'even'; ?>
来判断是 odd 还是 even,这样我们就可以为 odd 和 even 指定不同的风格样式,如交互背景或是左右分列显示。
drupal 5.x 默认的主题garland的node.tpl.php文件
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
我们可以修改为:
<div id="node-<?php print $node->nid; ?>" class="node-<?php global $node_count; print ($node_count++ % 2) ? 'odd' : 'even'; ?><?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
评论
发表新评论