DedeCMS织梦常见参数修改(一)
1.网站标题(优化):
{dede:field.title/}_{dede:global.cfg_webname/}
2.当前名称:
{dede:field name='typename'/}
3.导航条(父类、子类):
{dede:channel type='top' row='8' currentstyle="<li><a href='~typelink~' class='thisclass'>~typename~</a> </li>"} <li><a href='[field:typelink/]'>[field:typename/]</a> </li> {/dede:channel}
4.面包屑:
{dede:field name='position'/} //出来的效果是:首页 > 新闻动态 >
{dede:field name='position' runphp='yes'} @me=substr(@me,0,-2); {/dede:field} //出来的效果是:首页 > 新闻动态
生成的代码为 <a href="#">首页</a> > <a href="#">新闻动态</a>
函数的位置 include/typelink.class.php
参考网站:http://www.simple-studio.net/2011060216.shtml
注意:在列表页的时候 {dede:field name='position'/} 效果是 首页 > 联系我们 >
在封面页的时候 {dede:field name='positon'/} 效果是 首页 > 联系我们
少一个后边的 >
删除当前位置下的超链接,只保留文字..
方法1:
文件\include\arc.archives.class.php
文件\include\arc.listview.class.php
文件\include\arc.partview.class.php
把三个文件里面的这句
Fields['position'] = $this->TypeLink->GetPositionLink(true);
都改成
Fields['position'] = $this->TypeLink->GetPositionLink(false);
方法2:
{dede:field name='position' function="strip_tags(@me)"/}
或者
{dede:field name='position' function="html2txt(@me)"/}
参考网站:http://www.cnblogs.com/Byrd/archive/2011/04/27/2030458.html
5.关于列表页和内容页的分页代码和css样式(可以直接拿来使用):
ul.pagesize{width:620px; margin:20px auto 10px; text-align:center; padding-bottom:10px;} ul.pagesize a{padding:5px; margin-right:5px; color:#333333; text-decoration:none;} ul.pagesize span.thisclass{padding:5px; margin-right:5px; color:#fc0;} ul.pagesize span.pageinfo{}
列表页的php页面:include/arc.listview.class.php 分页代码
文章页的php页面:include/arc.archives.class.php 分页代码
也可以用文件夹下的各种酷炫分页效果。
6.控制标签的字数(如description或者info或者body):
[field:description function='cn_substr(@me,80)'/] [field:body function='cn_substr(@me,80)'/]
不足显示全文,超过显示省略号...
[field:title function='(strlen("@me")>26 ? cn_substr("@me",26)."…":"@me")'/]
7.调用时间函数(多用于新闻列表的时间):
[field:pubdate function="MyDate('Y-m-d H:i',@me)"/]
pubdate 更新时间(发布时间)--可以修改
senddate 出版时间--不可更改
8.替换<div></div>等html标签的用法:
{dede:field.body runphp="yes"} $a=str_replace('div','p','@me'); $b=str_replace('<br />','',$a); @me=str_replace(' ','',$b); {/dede:field.body}
9.自定义表单增加时间的方法:
后台显示:
①.修改dede/templets/diy_list.htm,42行
else后面加入
if($fielddata[1]=='datetime') { $fields[$field] = GetDateTimeMk($fields[$field]); }
前台显示:
②.templets/plus/list_diyform.htm 在以下位置添加上面的代码
其它附件</a>";
}
--------------------》》在这个的后面添加以下代码。保存就OK
if($fielddata[1]=='datetime') { $fields[$field] = GetDateTimeMk($fields[$field]); }
写在静态页面:
<tr style="display:none;"> <td align="right" valign="top">提交时间:</td> <td><input name="txtshowtime" type="text" id="txtshowtime" style="width:250px" class="intxt" /><script type="text/javascript"> function chandeTime(){ var date = new Date(); var year = date.getFullYear(); var month = date.getMonth()+1; //js从0开始取 var date1 = date.getDate(); document.getElementById("txtShowTime").value=year+"-"+month+"-"+date1+" "+date.toLocaleTimeString() ; window.setTimeout("chandeTime();",1000); } window.onload = chandeTime(); </script></td> </tr>
10.织梦的后台添加菜单选项卡:
dede/templets/index_menu2.htm
加入一个选项卡,我放在了141行,在那个if判断权限的条件外,这样可以让编辑人员看到
<a id='link9' class='mm'><div onClick="ShowMainMenu(9)">其他</div></a>
这里注意你的id,link9不要和上边的id重复,然后 后边的js方法ShowMainMenu中也要传入9,是对应的,
然后是下一步,还是这个页面,大概下边找到一些空的div,都是些id是ct加数字的,加上:
<div id='ct9'></div>
这里ct后边的数字对应你上边的数字
接下来找到 dede/inc/inc_menu.php 打开在最下边的一串---符号上边,加上
<m:top item='9_' name='资讯其他管理' notshowall='1' display='none' rank='sys_MakeHtml'> <m:item name='管理身份证' link='/plus/mood/mood_write_admin.php' rank='sys_MakeHtml' target='main' /> </m:top>
就可以在后台的 “其他”->“管理身份证” 中访问到你新加的功能了