摘要页2列的简单实现

原文:Two columns of teasers

编辑主题template.php,增加代码:

function _exampletheme_nodebreak($node) {
  static $count;
  if ($node->sticky) {
   return TRUE;
  }
  else {
    $count = is_int($count) ? $count : 1;
    $return = ($count % 2) ? FALSE : TRUE;
    $count++;
    //dprint_r('WOOT');
    return $return;
  }
}

然后编辑主题node.tpl.php,在最后增加代码:

<?php if (($page == 0) && _exampletheme_nodebreak($node)): ?>
<br class="clear" />
<?php endif; ?>

修改主题style.css,增加

#contentcenter .node.teaser {
  float: left;
  width: 223px; //for fluid layout use 50%
  margin-left: 20px; //for fluid layout set to 0;
  padding: 0;
}

相比交互的摘要页style class ,这个略微复杂一些。但是告诉我们实现的方法有很多,要举一反三。

该方法增加了判断是否是置顶的node

 if ($node->sticky) {
   return TRUE;
  }
  else {
...

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许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.