听蝉 發表於 2023-7-21 00:00:00

织梦dedecms首页调用指定栏目内容的标签详解

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        我们知道Dedecms开发起来很简单,但是dedecms的全局变量有字节限制,使得我们通过标签在首页无法调用大段的内容,尤其是包含了html标签的内容,但是dedecms有另外一种调用大段内容的方法,那就是通过sql语句来调用已保存的html内容。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        例如一般的企业网站都会有一个企业简介的栏目,这个栏目我们大部分使用{field:content /}标签来调用栏目设置里的栏目内容,但是这个字段在首页是无法使用。其实写一个sql语句就可以实现栏目内容在首页的调用:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:xml;toolbar:false;">
{dede:sql sql='Select content from dede_arctype where id=2'}

{/dede:sql}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        注意手动修改数据前缀dede_</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        如果简介栏目的ID是2的话,可以用上面的方法调用出全部的企业简介。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        如果觉得内容太多的话,我们可以截取一部分,具体sql语句如下:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:xml;toolbar:false;">
{dede:sql sql='Select content from dede_arctype where id=2'}

{/dede:sql}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        以上表示调用栏目ID为2的栏目内容,并且仅调用200字节长度。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        怎么样,是不是很简单,以后要在首页调用栏目内容是不是简单多了。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: 织梦dedecms首页调用指定栏目内容的标签详解