dede学习
手册http://help.dedecms.com/v53/
标签生成器http://tools.dedecms.com/dedetag_maker.html
首页跳转手机端
<title>{dede:global.cfg_webname/}</title>
<meta name="description" content="{dede:global.cfg_description/}" />
<meta name="keywords" content="{dede:global.cfg_keywords/}" />
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobileurl/}/index.php";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>
栏目页调整手机端
<title>{dede:field.title/}_{dede:global.cfg_webname/}</title>
<meta name="keywords" content="{dede:field name='keywords'/}" />
<meta name="description" content="{dede:field name='description' function='html2text(@me)'/}" />
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobileurl/}/list.php?tid={dede:field.id/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
内页调整手机端
<title>{dede:field.title/}_{dede:global.cfg_webname/}</title>
<meta name="keywords" content="{dede:field.keywords/}" />
<meta name="description" content="{dede:field.description function='html2text(@me)'/}" />
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobileurl/}/view.php?aid={dede:field.id/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>
导航输出
{dede:channel type='top' row='10' currentstyle="
<li><a href='~typelink~' ~rel~ class='con'><span>~typename~</span></a></li>
"}
<li><a href="[field:typeurl/]" >[field:typename/]</a></li>
{/dede:channel}
二级目录
{dede:channel typeid='7'}
[field:typelink /] [field:typename/]
{dede:arclist typeid='3' row='20'}
掉用单条文章内容
{dede:arclist col='1' idlist='65'}
[field:arcurl/] [field:title/]
调用单条栏目
{dede:type typeid="1"}
[field:typename/]
[field:typelink/]
[field:description/] 要添加sql语句
{/dede:type}
{dede:channelartlist type="26" }
{dede:field.title/} 标题
{dede:field.content/} 内容
{/dede:channelartlist}
打开include/taglib/type.lib.php。
找到里面的SQL语句,原来sql检索的字段中没有description描述字段,添加description字段后为SELECT id,typename,typedir,description,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE id=’$typeid’ “
然后{dede:type typeid='1'}[field:description/]{/dede:type}这样调用指定一个栏目的描述。
当前位置
{dede:field name='position'/}
List 给第一个增加class
{dede:list limit="20" orderby="id" orderway='asc'}
<li class="item [field:global name=autoindex runphp='yes'](@me==1)? @me='active':@me='';[/field:global]"><a href="javascript:void(0);">[field:title/]</a></li>
{/dede:list}
底部
{dede:global.cfg_powerby/} 版权
列表页
{dede:list pagesize="2" orderby='pubdate'}
[field:title/] 标题
[field:litpic/] 图片
[field:title/] [field:pubdate function="MyDate('Y-m-d',@me)"/] 时间
[field:description function="cn_substr(@me,140)"/]... 描述
[field:click/] 点击数
[field:arcurl/] 链接
{/dede:list}
{dede:pagelist listitem="pre,next,pageno" listsize="5"/} 和pagesize 配合使用
联动查询输出内容
零碎
{dede:field name='typename'/} 当前位置标题
{dede:field.description function="cn_substr(@me,255)"/} 截断
{dede:field name='position'/}位置
{dede:field.content/} 当前栏目内容
flag="c" 推荐 h头条
{dede:arclist typeid='9' row='50' addfields='body' channelid='17'}
[field:litpic/]图片
[field:title/]标题
[field:description/]描述
[field:body/] 主体
channelid频道id typeid 栏目id addfields频道字段
Tag标签
[field:id runphp='yes']
global $cfg_cmspath;
$tags = GetTags(@me);
$revalue = '';
$tags = explode(',', $tags);
foreach($tags as $key => $value){
if($value){
$revalue .= '<a href="'.$cfg_cmspath.'/tags.php?/'.$value.'/">'.$value.'</a> ';
}
}
@me = $revalue;
[/field:id]
遍历栏目 --通过栏目遍历里面内容
{dede:channelartlist type="13" type='son' }
{dede:field.typename/}
{dede:field.content/}
{dede:arclist addfields="titleone,titletwo,titlethree" channelid='17'}
[field:title/]
[field:titleone/]
{/dede:arclist}
{/dede:channelartlist}
调图片模型body里面的图片-在 \include\extend.func.php 最下面添加个方法
function getbodypics($string, $num)
{ preg_match_all("/<img([^>]*)\s*src=('|\")([^'\"]+)('|\")/",$string,$matches);
$imgsrc_arr = array_unique($matches[3]);
$count = count($imgsrc_arr);
$i = 0;
foreach($imgsrc_arr as $imgsrc)
{
if($i == $num) break;
$result .= "<img src=\"$imgsrc\"/>";
$i++;
}
return $result;
}
提取编辑框body图片
[field:mypic2 function=getbodypics(@me,3)/]
内容模板标签
{dede:field.mypic2 function=getbodypics(@me,3)/}
mypic2 是字段名
3 是输出几张图片
内页
{dede:field name='title'/} 当前标题
{dede:field.pubdate function="MyDate('Y-m-d H:i',@me)"/} 时间
{dede:field.source/} 阅读
{dede:field.body/} 正文内容
推荐
{dede:arclist orderby="pubdate" flag="c" limit="11"}
[field:title/] [field:pubdate function="MyDate('Y-m-d',@me)"/] [field:click/]
{/dede:arclist}
外
遍历增加class
<script>
$(".side-list-01 li").each(function(){
$num = $(this).index()+1;
$(this).find("b").addClass("sz"+$num);
});
</script>
给表单增加验证码
在自定义表单模板中添加验证码代码,如下:
<input name="validate" type="text" id="vdcode" style="text-transform:uppercase;" size="8"/><img id="vdimgck" align="absmiddle" onClick="this.src=this.src+'?'" style="cursor: pointer;" alt="看不清?点击更换" src="../include/vdimgck.php"/><a href="javascript:vide(-1);" onClick="changeAuthCode();">看不清? </a>
3、在当前页添加JS代码,如下:
//验证码
<script type="text/javascript" language="javascript">
function changeAuthCode(){var num =newDate().getTime();varrand= Math.round(Math.random()*10000); num = num +rand; $('#ver_code').css('visibility','visible');if($("#vdimgck")[0]){ $("#vdimgck")[0].src ="../include/vdimgck.php?tag="+ num;}returnfalse;}</script>
修改订单处理页面,打开网站根目录/plus/diy.php文件, 添加验证代码到第61行左右位置。如下
$validate=empty($validate) ? '':strtolower(trim($validate));
$svali=strtolower(GetCkVdValue());
if(($validate==''||$validate!=$svali)&&preg_match("/6/",$safe_gdopen)){
ResetVdValue();
ShowMsg('验证码不正确!',$dede_add,0,1000);exit;
}

给栏目增加图片副标题字段
https://jingyan.baidu.com/album/72ee561aae2920e16138dff9.html?picindex=10(注意!里面第四步修改文件不是catalog_add.php 而是catalog_edit.php)

浙公网安备 33010602011771号