左手指 發表於 2023-10-11 00:00:00

Dedecms文章标题长度修改方法小结

<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><br/></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>方法一,在artlist标签中直接加入 titlelen=要显示的长度即可</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>方法二,利用css控制显示自动隐藏超出部份</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        一般的文字截断(适用于内联与块):</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;</p><div class="msgborder" id="phpcode4" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
        .text-overflow {display:block;/*内联对象需加*/<br/>
        width:31em;word-break:keep-all;/* 不换行 */<br/>
        white-space:nowrap;/* 不换行 */<br/>
        overflow:hidden;<br/>
        /* 内容超出宽度时隐藏超出部分的内容 */<br/>
        text-overflow:ellipsis;<br/>
        /* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。<br/>
        */}</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        &nbsp;</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        表格文字溢出的定义:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;</p><div class="msgborder" id="phpcode5" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; "><br/>
        table{<br/>
        width:30em;<br/>
        table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */<br/>
        }<br/>
        td{<br/>
        width:100%;<br/>
        word-break:keep-all;/* 不换行 */<br/>
        white-space:nowrap;/* 不换行 */<br/>
        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */<br/>
        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/<br/>
        }</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        &nbsp;</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><strong>三、修改dedecms程序</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        进入dedecms的后台,在“模板管理”中的“标签源码管理”,找到arclist.lib.php ,点击“编辑”,找到</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        “$titlelen = AttDef($titlelen,30); ”条语句,把其中的30改为60或者更大的数值即可。当然你也可以在</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        includetaglib 这个目录中找到arclist.lib.php,然后同样的方法修改好,再传到你的空间。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><br/>
        修改完数据库后,发布文章标题长度应该没问题了,但是如果更改文章后标题又变成80字节了,这是因为</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        dedeactionarticle_eidt_action.php对标题进行了限制</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; "><br/>
        打开dedeactionarticle_eidt_action.php 找到44行 $title = cn_substr($title,80); 删除此行代码, 或者修改</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        为</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        &nbsp;</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "><div class="right"><span style="text-decoration:underline;">复制代码</span></div><p>&nbsp; &nbsp; &nbsp; &nbsp;
                代码如下:</p></div><div class="msgborder" id="phpcode6" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; ">&nbsp; &nbsp;
        $title = cn_substr($title,200);</div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        &nbsp;</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        还需要在phpmyadmin里执行下面的代码</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; ">&nbsp; &nbsp;
        &nbsp;</p><div class="msgheader" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; "><div class="right"><span style="text-decoration:underline;">复制代码</span></div><p>&nbsp; &nbsp; &nbsp; &nbsp;
                代码如下:</p></div><div class="msgborder" id="phpcode7" style="margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; ">&nbsp; &nbsp;
        ALTER TABLE `dede_archives` CHANGE `title` `title` VARCHAR( 200 )</div>
頁: [1]
查看完整版本: Dedecms文章标题长度修改方法小结