DedeCms常用模板标签   2小时学会织梦仿站(视频)

DedeCMS二次开发群

群号(23871657) DedeCMS二次开发
只适用于讨论DedeCms二次开发相关话题,其他闲聊、广告、斗图、捣乱请自重自觉,谢谢合作!

内容

列表

首页

头尾

手机

不常用模板标签   DedeCms织梦二次开发教程(博客)

DedeCMS二次开发群

群号(23871657) DedeCMS二次开发
只适用于讨论DedeCms二次开发相关话题,其他闲聊、广告、斗图、捣乱请自重自觉,谢谢合作!

array runphp

{dede:field name=array runphp=yes}
@me = (@me['litpic'] == '/images/defaultpic.gif' ? "" : "<div class='image_frame'><a href='{@me['arcurl']}'><img src='{@me['litpic']}'></a></div>"); 
{/dede:field}
[field:array runphp=yes]@me = (empty(@me['litpic']) ? "" : "<a href='{@me['arcurl']}' class='preview'><img src='{@me['litpic']}'/></a>"); [/field:array]
[field:array runphp=yes]
if($GLOBALS[autoindex]%4==0)@me="{@me['litpic']}";else @me="{@me['title']}";
[/field:array]

litpic runphp

[field:litpic runphp=yes]if(@me == '/images/defaultpic.gif')@me = ' style="display:none"';else @me = '';[/field:litpic]
{dede:field.litpic runphp=yes}if(@me == '/images/defaultpic.gif')@me = ' style="display:none"';else @me = '';{/dede:field.litpic}

ispart runphp 自定义字段

[field:ispart runphp=yes]if(@me == ''){@me = "";}else{@me = "字段内容为:@me";}[/field:ispart]
{dede:field.ispart runphp=yes}if(@me == '')@me = "";else @me = @me;{/dede:field.ispart}

May 15, 2017 时间格式

[field:pubdate function='strftime("%b %d, %Y",@me)'/]

channel currentstyle

<li{dede:field name=topid runphp=yes}if(@me)@me=''; else @me=' class="menuCur"';{/dede:field}><a href="{dede:field.typeid function=gettoptype(@me,link)/}">全部文章</a></li>
{dede:channel type='son' currentstyle="<li class='menuCur'><a href='~typelink~' title='~typename~'>~typename~</a></li>"}
<li><a href='[field:typelink /]' title='[field:typename/]'>[field:typename/]</a></li>
{/dede:channel}

jquery 栏目高亮

<script language="javascript" type="text/javascript">
$(document).ready(function(){ 
	var cat_id = "cat_{dede:field.typeid/}";
	var up_id = "cat_{dede:field.typeid runphp='yes'"}
   global $dsql ;
   $reid = $dsql->GetOne("SELECT reid FROM `#@__arctype` where id=@me");
   $reid = $reid['reid'];
   @me=$reid;
{/dede:field.typeid}";
    $(".sb_navul ul").each(function () {
        if ($(this).attr("id") == up_id || $(this).attr("id") == cat_id) {
            $(this).show();
        }
    });
	$("#cat_{dede:field.typeid/}").addClass("red");
});
</script>

<div class="sb_nav">
	<div class="sb_navul">
	{dede:channelartlist typeid=2}
		<li>
			<a href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}">{dede:field name='typename'/}</a>
			<ul id="cat_{dede:field name='typeid'/}" class="none">
			{dede:channel type='sun' row='20' noself='yes'}
				<li>
					<a href="[field:typeurl/]" title="[field:typename/]" id="cat_[field:id/]">[field:typename/]</a>
				</li>
			{/dede:channel}
			</ul>
		</li>
	{/dede:channelartlist}
	</div>
</div>

2017年1月10日 转时间戳,再单独拿Ymd

年:{dede:field.begin_time function="MyDate('Y',GetMkTime(@me))"/}
月:{dede:field.begin_time function="MyDate('m',GetMkTime(@me))"/}
日:{dede:field.begin_time function="MyDate('d',GetMkTime(@me))"/}

19/10/2017 转换 2017年10月19日

{dede:field.begin_time function="MyDate('Y年m月d日',GetMkTime(implode('-',array_reverse(explode('/',@me)))))"/}

二级、三级、四级

<ul>
	{dede:channelartlist row=7 typeid=top}
	<!-- 顶级 -->
	<li class="top">
		<a href="{dede:field.typeurl/}" >{dede:field name='typename'/}</a>
		<ul class="sub">
		{dede:channel type=son noself=yes}
		<!-- 二级 -->
		<li>
		<a href="[field:typeurl/]"  title="[field:typename/]">[field:typename/]</a>
		<ul>
<!-- 三级 -->
[field:id runphp=yes]
global $dsql;
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=@me And ishidden<>1 order by sortrank asc limit 0,10";
$dsql->SetQuery($sql);
$dsql->Execute('t');
$result = '';
while($row = $dsql->GetArray('t'))
{
    $typename = $row['typename'];
    $typeurl = GetOneTypeUrlA($row);
$result .= <<< TPL
<li><a href="{$typeurl}">{$typename}</a></li>
TPL;
}
@me = $result;
[/field:id]
		</ul>
		</li>
		{/dede:channel}
		</ul>
	</li>    
	{/dede:channelartlist}
</ul>
<!-- /Wiznav -->

<!-- 三级/四级 -->
[field:id runphp=yes]
global $dsql;
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=@me And ishidden<>1 order by sortrank asc limit 0,10";
$dsql->SetQuery($sql);
$dsql->Execute('t');
$result = '';
while($row = $dsql->GetArray('t'))
{
    $row['typeurl'] = GetOneTypeUrlA($row);
	$result .= "<a href='{$row[typeurl]}'>{$row[typename]}</a>";
	//四级
	$nsql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=$row[id] And ishidden<>1 order by sortrank asc limit 0,10";
	$dsql->SetQuery($nsql);
	$dsql->Execute('n');
	while($nrow = $dsql->GetArray('n'))
	{
		$nrow['typeurl'] = GetOneTypeUrlA($nrow);
		$result .= "<a href='{$nrow[typeurl]}'>{$nrow[typename]}</a>";
	}
}
@me = $result;
[/field:id]

dede:sql 根据自定义字段填的id获取文档

{dede:sql sql="SELECT * FROM #@__archives WHERE arcrank>-1 AND id in(~myid~) ORDER BY FIELD(id,~myid~)"}
<a href="[field:id runphp=yes]$id=@me;$url=GetOneArchive($id);@me=$url['arcurl'];[/field:id]"><img src="[field:litpic/]">[field:title/]</a>
<p>[field:description/]</p>
{/dede:sql}

还需要修改 include\taglib\sql.lib.php 让它支持数字

if(is_numeric(str_replace(',','',$refObj->Fields[$value])))
{
	$sql = str_replace($conditions[0][$key], addslashes($refObj->Fields[$value]), $sql);
}
else
{
	$sql = str_replace($conditions[0][$key], "'".addslashes($refObj->Fields[$value])."'", $sql);
}