织梦网站栏目管理部分如何修改二次开发

最近研究织梦二次开发,发现其他部分还好! 这网站栏目这里竟然用的ajax调用的!

然后还用了Cookie来设置历史改了哪个来展示!

在文件include/typeunit.class.admin.php的这个文件里面!

  $lastid = GetCookie('lastCid');
            if($channel==$id || $lastid==$id || isset($GLOBALS['exallct']) || $cfg_admin_channel=='array')
            {
                echo "<table bgcolor='#e6e6e6;' lay-size='sm' class='layui-table' width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
                $this->LogicListAllSunType($id," ");
                echo "    </table>\r\n";
            }

其实我们只要把这里的if删掉!这样就能把全部栏目调用出来了!


下面是依照规则改的版本!

我们首先看文件catalog_main.htm头部的脚本

function LoadSuns(ctid,tid)
 {
  if($DE(ctid).innerHTML.length < 10){
    $DE('img'+tid).src = 'images/dedecontract.gif';
    var myajax = new DedeAjax($DE(ctid));
    myajax.SendGet('catalog_do.php?dopost=GetSunLists&cid='+tid);
  }
  else{ 
  showHide(ctid,tid);  
  }
}

1、首先是判断

if($DE(ctid).innerHTML.length < 10){ 

这个其实在文件include/typeunit.class.admin.php 上面设置cookie那段! 他默认生成一个tr>td标记增加了一个id来控制显示! 然后通过字符数来判断! 这里我们可以把字符数判断增加到50


   echo "  <tr><td colspan='2' id='suns".$id."'>";
            $lastid = GetCookie('lastCid');
            if($channel==$id || $lastid==$id || isset($GLOBALS['exallct']) || $cfg_admin_channel=='array')
            {
                echo "    <table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
                $this->LogicListAllSunType($id," ");
                echo "    </table>\r\n";
            }
            echo "</td></tr>\r\n</table>\r\n";


2、然后他执行了一个ajax 这个只是获取到include/js/dedeajax2.js 的 DedeAjax脚本里面有很多 函数

var myajax = new DedeAjax($DE(ctid));

然后,他执行了里面的函数

myajax.SendGet('catalog_do.php?dopost=GetSunLists&cid='+tid);

代码如下

//用GET方式发送数据
this.SendGet = function(purl) {
    var gkey = "";
    var i=0;
    this.state = 0;
    //get参数
    if(this.keyCount!=-1)
    { 
        for(;i<=this.keyCount;i++)
        {
            if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
            else gkey += "&"+this.keys[i]+'='+this.values[i];
        }
        if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
        else  purl = purl + '&' + gkey;
    }
    DedeXHTTP.open("GET", purl, true);
    this.SendHead();
    DedeXHTTP.send(null);
};

3、然后我们跳转到catalog_do.php 找到GetSunLists 代码如下

else if($dopost=="GetSunLists")
{
    require_once(DEDEINC."/typeunit.class.admin.php");
    AjaxHead();
    PutCookie('lastCid', $cid, 3600*24, "/");//改变cookie用作默认加载的一项
    $tu = new TypeUnit();
    $tu->dsql = $dsql;
    echo "    <table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
    $tu->LogicListAllSunType($cid, " ");
    echo "    </table>\r\n";
    $tu->Close();
}

他直接引入了typeunit.class.admin.php

然后通过里面的LogicListAllSunType 把子栏目的内容生产出来!

image.png

最后就通过include/js/dedeajax2.js 里面的这个返回了内容!

image.png


我们就可以得到子栏目了!要改就按照这些内容改即可!


相关内容

发表评论

验证码:
点击我更换图片

最新评论