相关主题

燃烧的冰2021-11-02  4.2K+

PC端右侧,详情页根据 tag 猜你喜欢的相关内容,最多输出 20 条。直接再模板使用即可,样式自行修改。默认的bootstrap

<?php if ($thread['tag']) {
    $tagids = array_keys($thread['tag_fmt']);
    $arrlist = well_tag_thread_find($tagids, 1, 100);
    !$arrlist and $arrlist = well_tag_thread__find(array(), array('id' => 1), 1, 100);

    if ($arrlist) {
        $count = count($arrlist);
        $total = $count > $pagesize ? $pagesize : $count;
        $tidarr = $count > 20 ? array_rand($arrlist, $total) : array_keys($arrlist);

        $arrlist = well_thread_find_asc($tidarr, $total);
    }
}
?>
<!-- 判断是否有相关主题 开始 -->
<?php if (!empty($arrlist)) { ?>
<div class="card border-0 shadow-sm mb-3">
	<div class="card-header bg-white">
		<h3 class="h6 font-weight-400 my-0">
			猜你喜欢
		</h3>
	</div>
	<ul class="list-group list-group-flush">
		<!-- 循环输出相关主题 开始 -->
		<?php foreach($arrlist as $val) { ?>
		<li class="list-group-item bg-white">
			<h4 class="h6 my-0">
				<a href="<?php echo $val['url'];?>" class="d-block text-truncate">
					<?php echo $val['subject'];?>
				</a>
			</h4>
		</li>
		<?php } ?>
		<!-- 循环输出相关主题 结束 -->
	</ul>
</div>
<?php } ?>
<!-- 判断是否有相关主题 结束 -->
0