dede一些容易遗忘的知识

 

dedecms的arclist标签下调用自定义字段

 

{dede:arclist pagesize='12' typeid='10' channelid='2' addfields='wuxing,shuzi,ptitle,palt,tlink'}<dd><a href="http://[field:tlink/]"><img class="img" src="[field:litpic/]" alt="[field:palt/]" title="[field:ptitle/]"/></a></dd><ul>              <li><a href="http://[field:tlink/]" title="[field:ptitle/]">[field:title/]</a></li>        <li><img src="/image/sc.jpg" alt="" title=""></li>        <li>[field:description/]</li>        <li><span class="red">[field:wuxing/]</span><br>        <li><span class="red">[field:shuzi/]</span></li>          <p> <a href="http://[field:tlink/]" target="_blank"><img src="/image/xq.gif" alt="查看详情" title="查看详情"></a> </p>        </ul> {/dede:arclist}
注:要获取附加表内容,必须符合两个条件
1、指定 channelid 属性
2、指定要获得的字段 addfields='字段1,字段'
如:
{dede:arclist addfields='filetype,language,softtype' row='8' channelid='3'}
[field:textlink /] - [field:softtype /]<br />
{/dede:arclist}

 

 

dedecms高级搜索调用缩略图

 

{dede:field name='litpic' /}

 

 

dedecms去后台验证码

 

DATA文件夹里的\safe\inc_safe_config.php

$safe_gdopen = ’1,2,3,4,5,6′;这句代码

“6”删除了,就可以了。

 

 

dedecms密码重置

 

见附件:radminpass.rar

 

dede的php当前时间加/减天

 

当前时间:
{dede:php runphp='yes'}$ntime = time();@me=MyDate('Y-m-d',$ntime);{/dede:php}

当前时间减1天:
{dede:php runphp='yes'}$ntime = time();@me=MyDate('Y-m-d',strtotime('-1 day'),$ntime);{/dede:php}

 

详情查看php的strtotime() 函数。

 

dede自定义表单提交后直接弹出对话框

plus/diy.php查找

$goto = '/';
$bkmsg = '发布成功,请等待管理员处理...';

 

修改为:

echo'<script>alert("发布成功,请等待管理员处理...");history.go(-1);</script>';


dede后台自定义表单一页显示50条

后台/diy_list.php查找

$datalist->pageSize = 10;

 

修改为:

$datalist->pageSize = 50;

 

dede后台自定义表单全选功能

后台/templets/diy_list.htm查找

<b>内容列表</b>

 

在后添加:

<script>function SelectAll() { var checkboxs=document.getElementsByName("id[]"); for (var i=0;i<checkboxs.length;i++) {  var e=checkboxs[i];  e.checked=!e.checked; }}</script>
<a href="#" onclick="SelectAll()">全选/反选</a>

 

 

 

dede标题不受字数限制

 

[field:fulltitle/]

 

其中titlelen=’24′控制的是标题[field:title/]的字数为12个汉字,[field:fulltitle/]控制鼠标划过时提示完整标题名称。这样,无论是搜索引擎还是目标访客都相当友好了

dede按权重排序

{dede:arclist row='10' titlelen='34' isweight="Y" orderby='weight' typeid='3' idlist=''}

 

 我们在使用orderby='weight' 时需要在前面加上 isweight="Y" 来开启权重的使用

参考:http://jingyan.baidu.com/article/93f9803f0efb98e0e46f552c.html

{dede:list}增加按权重排序标签

1、打开\include\目录中的arc.listview.class.php文件,搜索“排序方式”,然后在

else if($orderby=="lastpost") {

$ordersql = " order by arc.lastpost $orderWay";

}

else if($orderby == "weight") {

$ordersql = " order by arc.weight asc";

}

else {

$ordersql=" order by arc.sortrank $orderWay";

}

这段代码中间添加以上红色代码。

4、向下找到if(ereg('hot|click|lastpost',$orderby))或者是if(preg_match('/hot|click|lastpost/', $orderby))修改成if(ereg('hot|click|lastpost|weight',$orderby))或者是if(preg_match('/hot|click|lastpost|weight/', $orderby)) ,保存文件。

这个时候在列表页里就可以使用{dede:list pagesize='5' orderby='weight'} 进行排序了。

 

 

dede导航栏顶级栏目和二级栏目同时调用

{dede:channelartlist typeid='top'}
<a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a>
{dede:channel type='son' noself='yes'}<div><a href="[field:typelink/]">[field:typename/]</a></div>{/dede:channel}
{/dede:channelartlist}

 

自定义模型,在arclist中调用自定义字段

只需要在arclist 中增加两个属性:
1.channelid 也就是模型的id,必须
2.addfields  需要调用的字段名,必须

例如:

{dede:arclist channelid=18 addfields='stname'}
stname:[field:stname/]
{/dede:arclist}

注意,需要在模型设置中,对应的字段开启“允许在列表底层中调用,默认只在文档模板中调用”的选项

 

dede数字递增,+后面加数字

 

 [field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global]

 

清空DEDE自定义表单所有数据

 

TRUNCATE TABLE `dede_diyform1;

直接调用上一篇地址和下一篇地址的代码如下

 

 

上一篇地址

{dede:prenext get='pro' runphp="yes"}preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\/a.*?>/sim', @me, $strResult, PREG_PATTERN_ORDER);@me=$strResult[1][0];{/dede:prenext}

下一篇地址

{dede:prenext get='next' runphp="yes"}preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\/a.*?>/sim', @me, $strResult, PREG_PATTERN_ORDER);@me=$strResult[1][0];{/dede:prenext}

 

 

 

 

 

 

 

 

dede调用二三级菜单

{dede:channelartlist typeid='11'}
                <li class="por_content_c"><a href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}">{dede:field name='typename'/}</a></li>
{dede:sql sql='Select * from #@__arctype where reid=~id~ ORDER BY id limit 0,200'}
                <li class="por_content_c1"><a href="[field:typedir/]/">[field:typename/]</a></li>
{/dede:sql}

{/dede:channelartlist}

 

 

id为需要调用二三级菜单的一级菜单ID

如果单独指定调用一个或者多个栏目的话
{dede:channelartlist typeid='1,2'}
在里面指定你需要调用的id即可,如:
            	{dede:channelartlist typeid='1'}
                <li class="por_content_c2"><a href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}">{dede:field name='typename'/}</a></li>
     {/dede:channelartlist}

 也可以用sql直接调用单独栏目的子栏目

附带一些css容易忘的:

鼠标移动变小手:style="cursor:pointer;
 

附件下载:

radminpass.rar1.84KB