交互的摘要页style class

原文:Alternating Teaser Classes

该文章通过修改主题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'; } ?>">

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <img> <em> <del> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6>
  • 自动断行和分段。
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.