主题详情

燃烧的冰2019-12-28  242

主题详情页部分扁平和门户,对应的文件为 view/htm/read.htm


单页详情 对应的文件为 view/htm/single_page.htm


//----- 页面当前位置和链接 -----

<ol class="breadcrumb d-none d-md-flex shadow border-light">
   <li class="breadcrumb-item">
      <!--- 此处为返回主页 ->
      <a href="<?php echo $conf['path'];?>" aria-label="<?php echo lang('index_page'); ?>">
         <i class="icon-home"></i>
      </a>
   </li>
   <li class="breadcrumb-item">
      <!--- 此处为当前主题所属版块名 ->
      <a href="<?php echo forum_format_url($forum); ?>">
         <?php echo $forum['name'];?>
      </a>
   </li>
   <li class="breadcrumb-item active">
      <!--- 此处为当前主题 ->
      <a href="<?php echo url('read-' . $tid); ?>" title="<?php echo lang('index_page');?>返回主题第一页">
         <?php echo $thread['subject'];?>
      </a>
   </li>
</ol>


//----- 内容  -----

<div class="card card-thread shadow border-white">
   <div class="card-body">
      <div class="media">
          <!-- 发表内容的用户头像 -->
          <a href="<?php echo url('user-'.$thread['uid']);?>" tabindex="-1">
            <img class="avatar-3 mr-3" src="<?php echo $thread['user_avatar_url'];?>">
          </a>
         <div class="media-body subject">
             <!-- 主题 -->
             <h1 class="break-all font-weight-bold">
             <?php echo $thread['subject'];?>
             </h1>
             
             <div class="d-flex justify-content-between small">
               <div>
                   <span class="username">
                       <!-- 内容作者 -->
                       <a href="<?php echo url('user-'.$thread['uid']);?>" class="text-muted font-weight-bold">
                           <?php echo $thread['username'];?>
                       </a>
                   </span>
                   
                   <!-- 主题发布时间 -->
                   <span class="date text-grey ml-2">
                       <?php echo $thread['create_date_text'];?>
                   </span>
                   
                   <!-- 主题浏览次数 -->
                   <span class="text-grey ml-2">
                       <i class="icon-eye"></i>&nbsp;
                       <?php echo $thread['views'];?>
                   </span>
                   
               </div>
               
               <!-- 编辑,要返回后台,不需要可删除 -->
               <div>
               <?php if($allowdelete || $allowupdate) { ?>
                   <span class="dropdown">
                       <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);" role="button" aria-haspopup="true" aria-expanded="false">
                           <?php echo lang('manage');?>
                       </a>
                       <span class="dropdown-menu dropdown-menu-right size0 py-0">
                           <?php if($thread['allowdelete']) { ?
                           <a data-href="<?php echo url('operate-delete-'.$tid);?>" href="javascript:void(0);" class="dropdown-item post_delete" isfirst="1">
                           <?php echo lang('delete');?>
                           </a
                           <?php } ?>
                       </span>
                   </span>
                   <?php } ?>
               </div
            </div>
         </div>
      </div>
      <hr />
      <!-- message 和 break-all 两个class必须保留 -->
      <div class="message break-all">
      
      <!-- 如果有评论 并且评论分页 则第一页显示内容 第二页之后只显示标题 -->
      <?php if($page == 1) { ?>
         <!--需要 主图 文字环绕 删除下面的注释代码即可-->
         <!--
         <div class="clearfix float-left mx-2">
         <img src="<?php echo $thread['icon_text'];?>" alt="<?php echo $thread['subject'];?>" />
         </div>
         -->
         
         <!-- 内容 -->
         <?php echo $data['message'];?>
         
         <!-- 附件 -->
         <?php echo data_file_list_html($thread['filelist']);?>
         
      <?php } else { ?>
      
         <!-- 评论第二页显示标题 -->
         <p>
            <a href="<?php echo url('read-' . $tid); ?>">
            <?php echo lang('view_thread_message');?>
            </a>
         </p>
         
      <?php } ?>
      
      </div>

      <!-- 插件位置 自制版模板删除,即使留了也有很多地方不兼容 -->
      <div class="plugin d-flex justify-content-center mt-3">
         <!--{hook read_plugin_body.htm}--> 
      </div>
      
      <!-- 判断是否有tag --> 
      <?php if ($page == 1) { ?>
      <?php if ($thread['tag']) { ?>
      <hr
      <div class="row"
        <div class="col-lg-12 text-muted mt-2">
          <i class="icon-tags mr-2"></i>
          <?php foreach($thread['tag_text'] as $_tag => $_tagname) { ?>
          <span class="badge border border-secondary mr-2">
              <h2 class="mb-0 small">
                  <a class="text-secondary" href="<?php echo url('tag-' . $_tag);?>">
                  <?php echo $_tagname; ?>
                  </a>
              </h2>
          </span>
          <?php }?
        </div>
      </div>
      <?php }?>
      <!--{hook read_random.htm}-->
      <?php }?>
   </div>
</div>


//----- 评论和评论分页  -----

<?php if ($forum['comment'] && $thread['closed'] < 2) { ?>
<div class="card card-postlist border-white shadow">
   <div class="card-body">
      <div class="card-title">
         <div class="d-flex justify-content-between">
            <div>
               <!-- 评论数量 -->
               <b><?php echo lang('new_post');?></b>(<span class="posts"><?php echo $thread['posts'];?></span>)
            </div>
            
            <!-- 钩子,自制模板删除即可 -->
            <div>
               <!--{hook read_comment_list_title_right.htm}-->
            </div>
            
         </div>
      </div>
      
      <ul class="postlist list-group list-group-flush">
      
         <!-- 加载公用评论列表文件 -->
         <?php include _include(APP_PATH.'view/htm/comment_list.inc.htm'); ?>
         
         <!-- 判断主题是否开启评论,与最下面有一处对应 -->
         <?php if(!empty($user) && $thread['closed'] == 0) { ?>
         
         <li class="row post newpost media">
         
            <!-- 钩子,自制模板删除 -->
            <div class="col-lg-12 d-flex justify-content-between small text-muted">
            <!--{hook read_comment_post_start.htm}-->
            <div>
            
            <!-- 评论头像 -->
            <a href="<?php echo url('user-'.$user['uid']);?>" tabindex="-1">
               <img class="avatar-1 mr-2" src="<?php echo $user['avatar_url'];?>">
            </a>
            
            <div>
            <!-- 评论楼层 -->
               <span class="floor" id="newfloor">
                  <?php echo ($thread['posts'] + 2);?>
               </span
               <?php echo lang('floor');?>
            </div>
            
            <!-- 评论框开始 -->
            <div class="col-lg-12">
            <!-- 评论表单 quick_reply_form 不要随意修改 -->
            <form action="<?php echo url('comment-create-'.$tid);?>" method="post" id="quick_reply_form" class="d-block">
               <!-- 此处原样复制 -->
               <input type="hidden" name="doctype" value="1" />
               <input type="hidden" name="return_html" value="1" />
               <input type="hidden" name="quotepid" value="0" />
               
            <div class="message mt-1">
               <!-- 评论框不要随意删减,与下面js有对应 -->
               <textarea class="form-control" placeholder="<?php echo lang('message');?>" name="message" id="message"></textarea>
            </div>
            
            <div class="text-muted mt-2 small text-center">
            
            <!-- 提交按钮 -->
               <button type="submit" class="btn btn-sm btn-secondary" id="submit" data-loading-text="<?php echo lang('submiting');?>...">
                  <?php echo lang('post_create');?>
               </button>
            </div>
            
            <!-- 表单闭合 -->
            </form>
          </div>
          <!-- 评论框结束 -->
         </li>
         <?php } ?>
      </ul>
   </div>
</div>

<!-- 评论分页 -->
<?php if($pagination) { ?>
   <nav>
      <ul class="pagination my-4 justify-content-center flex-wrap">
      <?php echo $pagination; ?>
      </ul>
   </nav>
<?php } ?>

<?php } ?> <!-- 评论结束闭合 -->


详情页自定义标签调用跟列表页相同,此处就不在贴代码


加载页头和页脚,然后在最下面加载 view/htm/read.htm 文件最下面的 js 代码,有文字标注,无需修改。