bucuo123 发表于 2019-4-5 14:52:00

Discuz!X帖子内容页增加阅读全文功能

Discuz!X帖子内容页增加阅读全文功能
            
            
       
               
                       
                               
                                       
                                                很多小伙伴可能碰到在看帖的时候帖子很长,鼠标滚轮滚很多次也看不到底的情况,这时候我们可以在帖子内容页增加阅读全文功能,实现非常简单,由于没有合适的嵌入点,不能做成插件,只能自己修改代码了,实现起来很简单,代码如下:
                                                一、找到 你的模板目录/forum/viewthread_node_body.htm,打开这个文件,找到第58行,
                                               
                                                       
                                                               
                                                                       
                                                                                  
                                                                               
                                                                                       
                                                                                               
                                                                                                       
                                                                                                               
                                                                                                       
                                                                                               
                                                                                       
                                                                               
                                                                       
                                                               
                                                       
                                                        复制代码
                                               
                                                给这个div增加一个id
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                               
                                                                                       
                                                                                               
                                                                                                       
                                                                                                               

                                                                                                       
                                                                                               
                                                                                       
                                                                               
                                                                       
                                                               
                                                       
                                                        复制代码
                                               
                                               
                                                {if $post['first',}{/if}这个判断是为了保证代码只在楼主这层有效。
                                               
                                                二、找到第180行,
                                               
                                                       
                                                               
                                                                       
                                                                                  
                                                                               
                                                                                       
                                                                                               
                                                                                                       
                                                                                                               
                                                                                                       
                                                                                               
                                                                                       
                                                                               
                                                                       
                                                               
                                                       
                                                        复制代码
                                               
                                                在此之前粘贴以下代码
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                       
                                                                                               
                                                                                                       
                                                                                                               
   
   
      
      阅读全文
   

   
复制代码
                                                                                                       
                                                                                               
                                                                                       
                                                                               
                                                                       
                                                               
                                                       
                                               
                                               
                                                三、css样式如下
                                                找到 你的模板目录/common/module.css 或 模板目录/common/extend_module.css,粘贴一下代码即可。
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                       
                                                                                               
                                                                                                       
                                                                                                               
/** forum::viewthread,group::viewthread **/
/*阅读全文按钮*/
.read_all { position: relative; margin-top: -200px;z-index:999; text-align: center; }
.read_all .read_more_mask { height: 200px; background: -moz-linear-gradient(bottom,rgba(255,255,255,0.1)]rgba(255,255,255,0)); background: -webkit-gradient(linear,0 top]0 bottom,from(rgba(255,255,255,0))]to(#fff)); background: -o-linear-gradient(bottom,rgba(255,255,255,0.1)]rgba(255,255,255,0)); }
.read_more_btn { display:inline-block; padding:0 20px; background: #fff; border-radius: 4px; border: 1px solid {HIGHLIGHTLINK}; cursor:pointer; font-size: 16px; color:{HIGHLIGHTLINK}; line-height: 32px; }
.read_more_btn:hover { background:{HIGHLIGHTLINK}; color:#fff; text-decoration:none;}
/** end **/
页: [1]
查看完整版本: Discuz!X帖子内容页增加阅读全文功能