公用列表

燃烧的冰2020-01-11  444

wellcms 模板中很多地方加载了公用列表文件,尤其是扁平模式下,首页、频道、列表、搜索页、用户中心、我的首页等很多地方都加载了这个文件,引用加载无需重复写代码,一个文件多处引用。


对应文件 view/htm/thread_list.inc.htm


其他文件加载该文件的代码如下,比如列表页

<!--
clas中的threadlist保留,为前台管理使用,不需要前台管理可删除。
-->
<ul class="threadlist list-group list-group-flush shadow">
   <?php include _include(APP_PATH . 'view/htm/thread_list.inc.htm');?>
</ul>


thread_list.inc.htm文件 此文件包含了管理代码,如果不需要前台管理,可删除掉管理代码,以下为该文件代码

<?php if($threadlist) { foreach($threadlist as &$_thread) { ?>

<!--
thread 为写好的每天标题下的分割底线
tap 为移动端点击整行跳转
data-href="" 为整行跳转路径
tid="" 为前台管理时使用的ID
-->
<li class="media thread tap bg-white" data-href="<?php echo $_thread['url']; ?>" tid="<?php echo $_thread['tid'];?>"

    <!-- 此处为前台管理使用表单 -->
    <?php if($_thread['allowtop']) { ?>
    <input type="checkbox" name="modtid" class="mt-3 mx-2" value="<?php echo $_thread['tid']; ?>" />
    <?php } ?>

    <div class="media-body">
        <div class="media">
        
        <!-- 此处代码为加载主题缩略图 开始 -->
            <?php if ($_thread['icon']) { ?>
            <div class="col-4 col-md-3"
                <a href="<?php echo $_thread['url']; ?>" <?php echo ($_thread['type']==10?'rel="nofollow" target="_blank"':''); ?>>
                    <img class="d-block w-100 rounded" src="<?php echo $_thread['icon_text'];?>" title='<?php echo $_thread['subject'];?>' alt='<?php echo $_thread['subject'];?>' />
                </a>
            </div>
            <?php } ?>
        <!-- 此处代码为加载主题缩略图 结束 -->
        
            <div class="media-body">
                <div class="col-lg-12 subject">
                
                    <!-- 此处为显示置顶字样 --> 
                    <?php if($_thread['sticky'] > 0) {?>
                    <span class="mr-2 font-weight-bold badge badge-<?php echo $_thread['sticky_class'];?>">
                         Sticky <!-- Sticky可改成置顶两个字 --> 
                    </span>
                    <?php } ?>
                    
                    <!-- 此处为显示主题是否被锁 --> 
                    <?php if($_thread['closed'] > 0) { ?>
                    <span class="mr-2">
                        <i class="icon-lock text-<?php echo $_thread['closed']==1?'danger':'dark';?>"></i>
                    </span>
                    <?php } ?>
                    
                    <!-- 此处为主题 原样复制即可,此处有主题外链跳转 -->
                    <h2 class="break-all font-weight-bold d-inline">
                        <a href="<?php echo $_thread['url']; ?>" aria-label="<?php echo $_thread['subject'];?>" <?php echo ($_thread['type']==10?'rel="nofollow" target="_blank"':''); ?>>
                            <?php echo $_thread['subject'];?>
                        </a>
                    </h2>
                    
                </div>
                
                <!-- 此处为摘要 -->
                <?php if($_thread['brief']){?>
                <div class="col-lg-12 text-muted brief mt-2">
                    <?php echo $_thread['brief'];?>
                </div>
                <?php }?>
                
                <!-- 此处为tag 开始 -->
                <?php if($_thread['tag']){?>
                <div class="tag hidden-sm col-lg-12 small text-muted mt-3">
                    <i class="icon-tags mr-2"></i>
                    <!-- 循环输出tag 开始 -->
                    <?php foreach($_thread['tag_text'] as $key => $_tag) {?>
                    <span class="mr-2">
                        <strong class="mb-0">
                            <a class="text-secondary" href="<?php echo url('tag-'.$key);?>">
                                <?php echo $_tag;?>
                            </a>
                        </strong>
                    </span>
                    <?php }?>
                    <!-- 循环输出tag 结束 -->
                </div>
                <?php }?>
                <!-- 此处为tag 结束 -->
                
                <div class="col-lg-12 text-grey mt-2">
                    <!-- 此处为发表主题者头像 -->
                    <a href="<?php echo url('user-' . $_thread['uid']);?>" tabindex="-1" class="mr-2">
                        <img class="avatar-1" src="<?php echo $_thread['user_avatar_url'];?>">
                    </a>
                    <!-- 此处为发表主题者昵称 -->
                    <span class="username text-grey mr-1" uid="<?php echo $_thread['uid'];?>">
                        <?php echo $_thread['username'];?>
                    </span>
                    <!-- 此处为发表主题时间 如需要显示年月日 改为 $_thread['create_date_text'] -->
                    <span class="date text-grey hidden-sm">
                        <?php echo $_thread['create_date_fmt'];?>
                    </span>
                    <!-- 此处为最后评论该主题的人 -->
                    <?php if($_thread['lastuid']) { ?>
                    <span>
                        <span class="hidden-sm text-grey mx-1">←</span>
                        <span class="hidden-sm username text-grey mr-1" uid="<?php echo $_thread['lastuid'];?>">
                            <?php echo $_thread['lastusername'];?>
                        </span>
                        <!-- 此处为最后评论该主题的时间 -->
                        <span class="text-grey hidden-sm">
                            <?php echo $_thread['last_date_fmt'];?>
                        </span>
                    </span>
                    <?php } ?>
                    
                    <div class="float-right text-muted small">
                    
                    <!-- 此处为主题被浏览次数 -->
                        <span class="mr-2 hidden-sm">
                           <i class="icon-eye mr-1"></i>
                           <?php echo $_thread['views'];?>
                        </span>
                        
                    <!-- 此处为主题被评论次数 -->
                        <span class="mr-2">
                            <i class="icon-comment-o mr-1"></i>
                            <?php echo $_thread['posts'];?>
                        </span>

                    </div>
                </div>
            </div>
        </div>
    </div>
</li>
<?php }} else { ?>
<li class="list-group-item">
    <!-- 此处为没有主题 -->
    <div><?php echo lang('none');?></div>
</li>
<?php } ?>