织梦全部代码之复制粘贴版


头部类写入文件

普通设置类

<meta http-equiv="Cache-Control" content="no-transform " />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />

引入文件类

<link rel="stylesheet" type="text/css" href="/basic/css/main.css">
<link rel="stylesheet" href="/basic/css/swiper3.css">
<script type="teXt/javascript" src="//apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>

主页

<title>{dede:global.cfg_webname/}</title>
<meta name="keywords" content="{dede:global.cfg_keywords/}" />
<meta name="description" content="{dede:global.cfg_description/}" />

主页跳转

    <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_basehost/}"; } else if (/iPad/i.test(navigator.userAgent)) {} else {} } catch (e) {} } } }
    </script>


列表页

<title>{dede:field.typename/}{dede:field.seotitle/}</title>
<meta name="keywords" content="{dede:field.typename/},{dede:field name='keywords'/}" />
<meta name="description" content="{dede:field.seotitle/}:{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_sjbdhost/}{dede:type row=1}[field:typelink /]{/dede:type}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>


文章页面

<title>{dede:field.shorttitle/}{dede:field.title/}</title>
<meta name="description" content="{dede:field.title/}--{dede:field.description function='html2text(@me) '/}" />
<meta name="keywords" content="{dede:field.title/},{dede:field name='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_sjbdhost/}{dede:field name='arcurl'/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

手机端rem转换脚本

<script type="text/javascript">
(function(doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = "orientationchange" in window ? "orientationchange" : "resize",
        recalc = function() { var clientWidth = docEl.clientWidth; if (!clientWidth) { return } if (clientWidth >= 640) { docEl.style.fontSize = "100px" } else { docEl.style.fontSize = 100 * (clientWidth / 640) + "px" } };
    if (!doc.addEventListener) { return } win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener("DOMContentLoaded", recalc, false)
})(document, window);
</script>


头部类引用标签

{dede:include filename="head1.htm"/}

{dede:include filename="head2.htm"/}

{dede:include filename="head.htm"/}

{dede:include filename="menu.htm"/}

{dede:include filename="footer.htm"/}

{dede:include filename="menu.htm"/}

{dede:include filename="left.htm"/}


获取顶级标题类

{dede:field.typeid function="GetTopTypelitpic(@me,typelitpic)"/}

{dede:field.typeid function="GetTopTypejj(@me,typejj)"/}

{dede:field.typeid function="GetTopTypeenname(@me,enname)"/}

{dede:field.typeid function="GetTopTypeicon(@me,icon)"/}

{dede:field.typeid function="GetTopTypename(@me,typename)"/}


<script type="text/javascript">
$(function(){
$(".zxzx").click(function(){
window.open("http://wpa.qq.com/msgrd?v=3&uin={dede:global.cfg_qq/}&site=qq&menu=yes");
         return false;
        })
})
</script>

    <script type="text/javascript">
$(function(){
$(".zxzx").click(function(){
    window.open("mqqwpa://im/chat?chat_type=wpa&uin={dede:global.cfg_qq/}&version=1&src_type=web&web_src=");
         return false;
        })
})
</script>


获取banner

{dede:sql sql="Select * from dede_flink where typeid=2 order by sortrank asc LIMIT 0,5"}
   <div class="banner-slide">
        <a href="[field:url/]" title="[field:webname/]">
             <img class="bn-img" src="[field:logo/]" alt="[field:webname/]">
                            </a>
            </div>
{/dede:sql}

手机端则 [field:global.cfg_basehost/][field:email/]

当前位置:{dede:field.position/}



织梦调用当前栏目下 三级栏目当前栏目的办法   缺陷就是如果用的一个模板  进入了三级栏目后将没有!

{dede:sql sql='Select * from dede_arctype where reid=~id~'}
    
[field:typename/]
 
{/dede:sql}


列表

{dede:list pagesize='9' imgwidth=137 imgheight=205 infolen="360" }
[field:title/]
[field:title function='( strlen("@me")>25 ? cn_substr("@me",25)."..." : "@me" )'/]
[field:info function='( strlen("@me")>45 ? cn_substr("@me",45)."..." : "@me" )'/]
[field:arcurl/]
[field:global.cfg_basehost/]
[field:litpic/]
[field:pubdate function='strftime("%Y-%m-%d",@me)' /]
 class="lazy" data-original="[field:litpic/]"  alt="[field:title/]"
{/dede:list}

//orderby排序hot或click点击数;sortrank或pubdate出版时间;near,lastpost评论时间;scores得分;id文章ID;rand随机

orderway='desc' asc

 {dede:pagelist listitem="index,end,pre,next,pageno" listsize="5"/}


[field:global name='autoindex' runphp='yes']

if(@me==2){@me="";}else{@me=' ';}

[/field:global]


$base=$GLOBALS['cfg_basehost'];


织梦列表多级模式,部分有二级部分无二级

   <script type="text/javascript">
        $(function(){
var cp_name=$('.cp-menu').attr('data-name');
$('.cp-menu1 li').each(function(){
  var dq_name=$(this).find('a').html();
  if(dq_name.indexOf(cp_name) >= 0 ){
    $(this).addClass('this');
  }
})

var a=$('.cp-menu').find('li').eq(1).find('a').html();
var b=$('.cp-menu2 li').eq(1).find('a').html();
if(a==b){
                $('.cp-menu2').hide();
            }
    //判断上级id增加class
var sjid=$('.cp-menu2').attr('data-id');
if(sjid){
	$('.'+sjid).addClass('this');
}        

        })
    </script>



三图模式

              [field:array runphp='yes'] if (@me['open']=='yes') @me = "
                        <a href=".@me['arcurl']." class='list-t3'>
                            <div class='txt'>
                                <h5>".@me['title']."</h5>
                                <p>".@me['infos']."</p>
                            </div>
                            <div class='list-imgs'>
                              <div class=list-img> <img  width='400' height='300' src=".$GLOBALS['cfg_basehost'].@me['litpic1']." /> </div> 
                                          <div class=list-img> <img  width='400' height='300' src=".$GLOBALS['cfg_basehost'].@me['litpic2']." /> </div> 
                                                     <div class=list-img> <img  width='400' height='300' src=".$GLOBALS['cfg_basehost'].@me['litpic3']." /> </div> 
                            </div>
                        </a>
                        "; else @me="
                        <a href=".@me['arcurl']." class=list-t1>".@me['image']."<div class='txt'><h5>".@me['title']."</h5><p>".@me['infos']."</p></div>
  
</a> "; [/field:array]

判断是否有略缩图

                [field:array runphp='yes']
    @me=(strpos(@me['litpic'],'defaultpic')?'':"<div class=img><img src='{@me['litpic']}' alt='{@me['title']}'/></div>");
[/field:array]


点击加载更多


    <script type="text/javascript">
                //加载更多
                $(function() {
                    i = 0;
                    $("#getMore").click(function() {
                        var _this = $(this),
                            pnum = _this.attr("pnum"), //分页码
                            typeid = {dede:field.typeid/}; // 栏目ID
                        if (pnum == 0) {
                            return false;
                        }
                        $.ajax({
                            url: '/arc_ajax_new.php',
                            data: { typeid: typeid, pnum: pnum },
                            success: function(data) {
                                if (data != '') {
                                    $(".jznr").append(data); //数据显示到页面
                                    _this.attr("pnum", Number(pnum) + 1); //分页+1
                                } else {
                                    _this.text("没有更多的内容");
                                    _this.attr("pnum", 0);
                                    _this.addClass("jz_none")
                                }
                                $("#loadingjz").hide();
                            }
                        })
                        return false;
                    })


                })
                </script>


缓加载

<script type="teXt/javascript" src="/basic/js/jquery.lazyload.js"></script>
<script type="text/javascript">
$(function() {
    $(document).ready(function() {
        $(".lazy").lazyload({
            effect: "fadeIn", //渐现,show(直接显示),fadeIn(淡入),slideDown(下拉)
            threshold: 80, //预加载,在图片距离屏幕180px时提前载入
            event: "scroll", // 事件触发时才加载,click(点击),mouseover(鼠标划过),sporty(运动的),默认为scroll(滑动)
            placeholder: "/basic/images/loading.gif", //用图片提前占位
            skip_invisible: false,//在需要点击显示的部位,也进行加载
        });
    });
});
</script>


文章页面

{dede:field.title/}

{dede:field.body/}

{dede:field.source/}

{dede:field.body function='replaceurlsj(@me)'/}

标签:{dede:field.tags function='Tagslink(@me)'/}

{dede:field.id function="zan(@me)"/}

 <div class="arc-tags">标签:{dede:field.tags function='Tagslink(@me)'/}</div>

{dede:field.title/}

{dede:field.click/}


{dede:prenext get='pre' function="str_replace('上一篇:没有了 ','上一篇:<a href="{dede:global.cfg_basehost/}/#/" title=" [简介]" target=_blank/> [简介]</a>',@me)"/}


<script type="text/javascript">
$(window).load(function(){
$.post("/counts.php?view=yes",{
aid:200,
mid:1
},function(data,textStatus){
console.log(data.click);
$(".wz-click").html(data.click);
},"json")
})
</script>

{dede:field.pubdate function='strftime("%Y-%m-%d",@me)'  /}

{dede:prenext get='pre'/}

{dede:prenext get='next'/}

{dede:field name='keywords'/}

{dede:field.description function='html2text(@me) '/}


{dede:field.body function='replaceurlsj(@me)'/}

点赞

<span class="dz zan-num" dir="{dede:field.id/}"><i class="iconfont icon-aixin"></i><span class="zan-size">{dede:field.id function="zan(@me)"/}</span>人点赞</span>
 <script language="javascript" type="text/javascript">
    $(function() {
        $(".zan-num").click(function() {
            var zan = $(this);
            var id = zan.attr("dir"); //对应id  
            // zan.find("i").fadeOut(300); //渐隐效果  
            $.ajax({
                type: "POST",
                url: "/zan.php",
                data: "id=" + id,
                cache: false, //不缓存此页面  
                success: function(data) {
                    zan.find(".zan-size").html(data);
                    zan.addClass('this'); //渐显效果  
                }
            });
            return false;
        });
    });
    </script>


百度分享

  <span class="bdsharebuttonbox bdshare-button-style0-16" data-tag="share_1" data-bd-bind="1524993340257">
      分享到: 
           <a href="#" class="iconfont icon-qqkongjian" data-cmd="qzone" title="分享到QQ空间"></a>
           <a href="#" class="bds_tsina iconfont icon-weibo" data-cmd="tsina" title="分享到新浪微博"></a>
           <a href="#" class="bds_weixin iconfont icon-weixin" data-cmd="weixin" title="分享到微信"></a>
           <a href="#" class="bds_sqq iconfont icon-qq" data-cmd="sqq" title="分享到QQ好友"><i class=""></i></a>
        </span>
        
<!--百度分享-->
<script>
    window._bd_share_config = {
            common : {      
            bdText : '{dede:field.title/}',  
            bdDesc : '{dede:field.description function="html2text(@me) "/}',   
            bdUrl : '{dede:global.cfg_basehost/}{dede:field.arcurl/}',    
            bdPic : '{dede:global.cfg_basehost/}{dede:field.dt/}',    
            },
        
            share : [{
            "tag" : "share_1",
    bdCustomStyle:" ",
        }]
    }
    //以下为js加载部分
    with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>


上下篇链接

 <li><a href="{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}"><i class="iconfont icon-zuo"></i><span>{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[2][0];    
{/dede:prenext}</span></a></li>
                <li class="go-type">{dede:type}<a href="[field:typeurl/]">{/dede:type}<i class="iconfont icon-liebiao"></i><span>返回列表</span></a></li>
            <li>
            <a href="{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}">
<span>
{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[2][0];
{/dede:prenext}</span>
<i class="iconfont icon-you"></i></a></li>

TAG标签调用大全

列表页

[field:id function=GetTags(@me)/]

列表增加链接,主要运用的是织梦自带函数GetTags,然后根据,进行php切割

[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>&nbsp;';         
   }      
  }        
@me = $revalue;     
[/field:id]

文章页

详细:http://www.xhcss.com/xh/dedecms/question/175.html

{dede:tag sort='new' getall='0'}
<a href='[field:link/]'>[field:tag /]</a>
{/dede:tag}

全局 getall='0'为当前页面,getall='1'为全站

new为最新,month为本月,rand为随机

   {dede:tag row='60' getall='1' sort='new'}
            <a href='[field:link/]' class='tagc[field:highlight /]'>[field:tag /]</a>
            {/dede:tag}



点击次数加载

<script type="text/javascript">
$(window).load(function(){
        $.post("/counts.php?view=yes",{
        aid:250,
        mid:1
        },function(data,textStatus){
            console.log(data.click);
            $(".wz-click").html(data.click);
        },"json")
        
        
    })
    
    </script>

表单部分

 <form action="/plus/diy.php" enctype="multipart/form-data" method="post" onsubmit="return chkForm(this);">
                <input type="hidden" name="action" value="post">
                <input type="hidden" name="diyid" value="1">
                <input type="hidden" name="do" value="2">
                    <li class="bd1">
                        <input type="text" name="bd1" class="bd-input" id="bd1" placeholder="姓名">
                    </li>
                    <li class="bd2">
                        <input type="text" name="bd2" class="bd-input" id="bd2" placeholder="电话 ">
                     </li>
                    <li class="bd3 ">
                       <input type="text " name="bd3" class="bd-input" id="bd3" placeholder="地址">
                    </li>
                    <li class="bd4">
                        <textarea class="tsly" id="bd4" name="beizhu" placeholder="备注">备注</textarea>
                    </li>
                    <div class="clear"></div>
                                           <input type="hidden" name="time" id="timee" class="textS" value="">
                    <script>
                    //显示当前日期时间
                    function refreshCalendarClocke() {
                        var d = new Date();
                        theDay = d.getDay();
                        var week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
                        document.getElementById("timee").value = new Date().toLocaleString();
                    }
                    setInterval('refreshCalendarClocke()', 1000);
                    </script>
                         <input type="hidden" name="dede_fields" value="bd1,text;bd2,text;nativeplace,stepselect;bd3,text;bd4,text;time,datetime;beizhu,multitext">
<input type="hidden" name="dede_fieldshash" value="5285644586ce18bb6c53d560180c1e42">
                    <div class="submit">
                        <input type="submit" class="bd-submit" value="提交">
                    </div>
                         </form>
<script type="text/javascript">
    //表单简单验证
    $(function(){
function chkForm(obj) {
        String.prototype.Trim = function() {
            return this.replace(/(^\s*)|(\s*$)/g, "");
        }
        if (obj.bd1.value.Trim().length < 1) {
            obj.bd1.focus();
            alert("姓名不能为空");
            return false;
        }

        if (obj.bd2.value.Trim().length < 7) {
            obj.bd2.focus();
            alert("电话号码不正确,请您重新输入  ");
            return false;
        }
        return true;
    }
 })
</script>


写的好!

微信扫一扫赏大洋