本篇文章给大家谈谈dedecms使用SQL代码调用指定栏目tag标签,同时本文还将给你拓展dedecmstag标签伪静态的修改方法_dedecms_CMS教程、dedecms调用指定栏目,指定作者,指
本篇文章给大家谈谈dedecms使用SQL代码调用指定栏目tag标签,同时本文还将给你拓展dedecms tag标签伪静态的修改方法_dedecms_CMS教程、dedecms 调用指定栏目,指定作者,指定自定义字段、Dedecms5.7列表页模板成功调用TAG标签、dedecms任意页面调用指定栏目内容的方法等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:- dedecms使用SQL代码调用指定栏目tag标签
- dedecms tag标签伪静态的修改方法_dedecms_CMS教程
- dedecms 调用指定栏目,指定作者,指定自定义字段
- Dedecms5.7列表页模板成功调用TAG标签
- dedecms任意页面调用指定栏目内容的方法
dedecms使用SQL代码调用指定栏目tag标签
在使用织梦dedecms建站中,很有可能需要用到在首页根据调用某个栏目下的TAG,也就是是按栏目调出TAG,这里就需要用到DEDE 的sql运行功能{dede:sql sql="select * from dede_archives a left join dede_taglist t on a.id=t.aid where a.typeid='22' limit 4"}
PHP?[field:tag/]" target="_blank" title="[field:tag /]" >[field:tag="" ]<="" a>
{/dede:sql}
这里typeid=‘22’可以改成你实际要调用的栏目ID,limit 4这个是调用多少个TAG出来
以上的代码是随便哪里都可以用
如果是要再栏目页调用,还有一个代码
[field:id runPHP=yes]
$tsql = new Dedesql(false);
$tags = '';
$tsql->SetQuery("Select i.tagname From dede_tag_list t left join dede_tag_index i on i.id=t.tid where t.aid='@me'");
$tsql->Execute('t');
while($row = $tsql->GetArray('t',MysqL_ASSOC)){
$tags .= "PHP?/".urlencode($row[" tagname'])."'>".$row['tagname']."<="" a>";=""
}
@me=$tags;
[/field:id]
如果是DEDE5.7 及之后的版本,可以直接在栏目页用
PHP?/".urlencode($row[" tagname'])."'>".$row['tagname']."<="" a>";=""
[field:id function=GetTags(@me)/] 就能直接调用,但是调用出来是不带链接的,如果需要链接,请注释掉include\helpers\archive.helper.PHP文件的130行: $tags .= ($tags=='' ? $row['tag'] : ','.$row['tag']); 用下面语句替换,当然你也可以加入自己的样式:$tags .= "PHP?/".urlencode($row[" tag'])."="" '>".$row['tag']."<="" a>="" ";<="" pre="">
dedecms tag标签伪静态的修改方法_dedecms_CMS教程
dedecms tag标签伪静态的修改方法,需要的朋友可以参考下。
一、dede后台开启伪静态
二、修改 /include/taglib/tag.lib.php
找到 $row[''link''] = $cfg_cmsurl."/tags.php?/".urlencode($row[''keyword''])."/";
改成 $row[''link''] = $cfg_cmsurl."/tags/".urlencode($row[''keyword'']).".html";
三、打开templets/default/taglist.htm
找到
当前位置::主页 > TAG标签 > {dede:field.title /}
修改为
当前位置::主页 > TAG标签 > {dede:field.title /}
四、httpd.ini 文件里加
RewriteRule ^(.*)/tags\.html $1/tags\.php
RewriteRule ^(.*)/tags/(.*).html $1/tags\.php\?$2
搞定啦~
新版本可以用下面的方法:
一、dede后台开启伪静态
二、修改 /include/taglib/tag.lib.php,找到:
$row[''link''] = $cfg_cmsurl."/tags.php?/".urlencode($row[''keyword''])."/";改成
$row[''link''] = $cfg_cmsurl."/tags/".urlencode($row[''keyword'']).".html";三、打开templets/default/taglist.htm,找到:
当前位置::主页 > TAG标签 > {dede:field.title /}修改为
当前位置::主页 > TAG标签 > {dede:field.title /}四、httpd.ini 文件里加
RewriteRule ^(.*)/tags\.html $1/tags.php;RewriteRule ^(.*)/tags/(.*).html $1/tags.php?/$2;
然后进入dede后台更新缓存后,就搞定了。
dedecms 调用指定栏目,指定作者,指定自定义字段
百度知道里看到有人提问,帮写了一个。
模板里调用sql:
1
2
3
4
5
6
|
{dede:sql sql= "select a.id,a.title,a.writer,a.pubdate,a.typeid,b.aid,b.sex from dede_archives a LEFT JOIN dede_addonarticle b on b.aid=a.id where a.typeid='7' and a.writer=~writer~ and b.sex='男' order by a.pubdate desc LIMIT 0,5" }
|
a.typeid=7 调用ID为7的栏目 如果不需要指定栏目ID 那么你可以把 a.typeid='7' and 删掉
a.writer=~writer~ 调用当前文章的作者,调用指定的作者,可以这样写a.writer='admin' 这样就是指定调用admin这个作者的文档
b.sex=男 设置性别,也就是自定义字段。如果你的自定义字段不是sex 那么你只要把sql里的b.sex 改成你的字段,例如 name 改成b.name
LIMIT 0,5 设置要调用的条数,我这里写的是5条,自行修改.
指定调用2个栏目的话 可以把where a.typeid='7' 修改为 where a.typeid='7' and a.typeid='8'
这样就指定调用栏目ID 为 7和8的栏目
GetoneDocUrl 函数 放到incluce/extend.func.PHP 文件中,这个函数是用来调用文档的静态URL的。
function GetoneDocUrl( $aid )
{
global $dsql ;
include_once (DEDEINC. "/channelunit.func.PHP" );
$aid = trim( ereg_replace ( '[^0-9]' , '' $chRow = ->Getone( "Select arc.*,ch.maintable,ch.addtable,ch.issystem From `dede_arctiny` arc left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' " );
if (! is_array ( $chRow )) {
return $reArr ;
}
else {
( empty [ 'maintable' ])) ] = 'dede_archives' ;
}
'issystem' ]!=-1)
{
$nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
From `{ ]}` arc left join `dede_arctype` tp on tp.id=arc.typeid
where arc.id= '$aid' ";
}
else
{
ismake,0 money,monospace; Box-sizing: content-Box !important; padding: 0px !important; color: blue !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important; word-break: break-all !important; background: none !important;">'' filename,tp.sitepath
'addtable' ]}` arc left join `dede_arctype` tp on tp.id=arc.typeid
where arc.aid= ";
}
$arcRow ->Getone( $nquery );
$Url = GetFileUrl( $arcRow 'typeid' ],monospace; Box-sizing: content-Box !important; padding: 0px !important; color: blue !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; min-height: auto !important; word-break: break-all !important; background: none !important;">'senddate' 'title' 'ismake' 'arcrank' 'namerule' 'typedir' 'money' 'filename' 'moresite' 'siteurl' 'sitepath' ]);
$Url ;
}
|
Dedecms5.7列表页模板成功调用TAG标签
经过查找终于找到了不错的解决方法
只不过不带连接的,如果需要连接,请注释includehelpersarchive.helper.PHP文件130行
// $tags .= ($tags==” ? $row['tag'] : ‘,’.$row['tag']);
用下面语句替换,当然你也可以加入自己的样式
$tags .= "PHP?/".urlencode($row['tag'])."/’>".$row['tag']."
调用时使用[field:id function=GetTags(@me)/] 标签就可以调用出来了
需要的朋友快去试试吧
dedecms任意页面调用指定栏目内容的方法
我们在使用Dedecms织梦建站的时候,经常把内容写到栏目内容中作为单页使用,比如公司简介、联系我们等等单页都可以写到栏目内容中,我们要调用的时候要怎么实现呢?小编为您整理了两种方法:
1、通过sql语句实现调用,写法如下:
{dede:sql sql='Select content from dede_arctype where id=1'}
[field:content function="cn_substr(Html2text(@me),340)"/]
{/dede:sql}
你需要修改的地方:
id=1' 意思是 id=栏目ID号,340是你要截取的字符数量,也就是最多截取170个汉子,html2text(@me)是过滤HTML字符,把HTML标记排除掉不显示。
2、第二种方法,直接通过type标签实现,写法如下:
{dede:type typeid=1}[field:content function="cn_substr(Html2text(@me),340)"/]{/dede:type}
但是这种写法的话,首先要修改一个文件,文件位置在/include/taglib/type.lib.PHP,在大约24行,找到如下代码,加入红色部分(原来的写法里面是没有写栏目内容的调用):
$row = $dsql->Getone("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,content,moresite,siteurl,sitepath FROM `dede_arctype` WHERE id='$typeid' ");
今天关于dedecms使用SQL代码调用指定栏目tag标签的介绍到此结束,谢谢您的阅读,有关dedecms tag标签伪静态的修改方法_dedecms_CMS教程、dedecms 调用指定栏目,指定作者,指定自定义字段、Dedecms5.7列表页模板成功调用TAG标签、dedecms任意页面调用指定栏目内容的方法等更多相关知识的信息可以在本站进行查询。
本文标签: