"盖楼"这个说法源于网络文化,尤其是在论坛、社交媒体和新闻网站等网络平台上非常常见。很多网站最经典的是什么,比如网易,他们经典的是评论,评论中最经典的呢,那就是盖楼......
下面给大家分享两种不同的"盖楼"方式,根据自己的实际情况将以下代码复制粘贴到对应的位置即可。
效果展示
1.盖楼
<?php
$floor = 1; // 初始化楼层为1
$db = Typecho_Db::get();
$sql = $db->select()
->from('table.comments')
->where('table.comments.cid = ?', $comments->cid)
->where('table.comments.status = ?', 'approved')
->order('table.comments.created', Typecho_Db::SORT_ASC);
$result = $db->fetchAll($sql);
foreach ($result as $row) {
if ($row['created'] < $comments->created) {
$floor++;
}
}
$floorText = $floor == 1 ? '1个脚印' : ($floor == 2 ? '2楼' : ($floor . '楼'));
?>
<span class="reply joe_comment__reply" data-id="<?php $comments->theId(); ?>" data-coid="<?php $comments->coid(); ?>">
<?php echo '第' . $floorText; ?>
</span></code></pre>
### 2.顶楼
```lang-html
<span style="margin-left:5px;color:#617d0e;font-size:12px">
<?php if($comments->levels == 0): ?>
<?php if($comments->sequence == 1): ?>沙发
<?php elseif($comments->sequence == 2): ?>板凳
<?php elseif($comments->sequence == 3): ?>地毯
<?php else: ?>
第<?php $comments->sequence(); ?>楼<?php endif; ?>
<?php endif; ?>
</span>
...
```