用dTree改造dedeeims产品目录
客户反映:点击产品目录其中一个分类后自动返回到一级分类,要求实现点击后产品信息更新但目录结构不变,其实就是局部刷新功能。
解决:
两个方案
1.AJAX技术实现网页无闪自动局部刷新
2.直接用JS实现
下面就介绍用dTree来做
dTree优点有(作者的网站 http://destroydrop.com/javascripts/tree/)
1.无限级分类
2.可用于内嵌框架
3.自动记录状态(跳转页面后目录仍然保持最后状态不会还原成全部折叠)
4.可在一个页面上存在多个DTREE
5.支持所有常用浏览器
√Internet Explorer 5+
√Netscape 6+
√Opera 7+
√Mozilla FireFox
6.符合XHTML 1.0
7.可替换图片
修改cattree.lib.php标签(加粗部分为更改过),
if(!defined(‘DEDEINC’)) exit(“Request Error!”);
function lib_cattree(&$ctag,&$refObj)
{
global $dsql,$cfg_df_lang;
//属性处理
//属性 showall 在空或不存在时,强制用产品模型id;如果是 yes 刚显示整个语言区栏目树;为其它数字则是这个数字的模型的id
//typeid 指定顶级树 id ,指定后,前一个属性将无效
$attlist=”showall|,catid|0″;
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$revalue = ‘<div>’;
$revalue .= ‘<script type=”text/javascript”>’;
$revalue .= “d = new dTree(‘d’);\n”;
$lang = (isset($refObj->dtp->tplLang) ? $refObj->dtp->tplLang : $cfg_df_lang);
if(empty($typeid))
{
if( isset($refObj->TypeLink->TypeInfos[‘id’]) ) {
$typeid = $refObj->TypeLink->TypeInfos[‘id’];
$reid = $refObj->TypeLink->TypeInfos[‘reid’];
$topid = $refObj->TypeLink->TypeInfos[‘topid’];
$lang = $refObj->TypeLink->TypeInfos[‘lang’];
$channeltype = $refObj->TypeLink->TypeInfos[‘channeltype’];
$ispart = $refObj->TypeLink->TypeInfos[‘ispart’];
if($reid==0) $topid = $typeid;
} else {
$typeid = $reid = $topid = $channeltype = $ispart = 0;
}
}
else
{
$row = $dsql->GetOne(“Select reid,topid,lang,channeltype,ispart From `#@__arctype` where id=’$typeid’ “);
if(!is_array($row)) {
$typeid = $reid = $topid = $channeltype = $ispart = 0;
} else {
$reid = $row[‘reid’];
$topid = $row[‘topid’];
$lang = $row[‘lang’];
$channeltype = $row[‘channeltype’];
$ispart = $row[‘ispart’];
}
}
if( !empty($catid) ) {
$topQuery = “Select id,typename,typedir,isdefault,defaultname,ispart,namerule2 From `#@__arctype` where reid=’$catid’ And ishidden<>1 “;
} else
{
if($showall == “yes” ) {
$topQuery = “Select id,typename,typedir,isdefault,defaultname,ispart,namerule2 From `#@__arctype` where reid=’$topid’ “;
}
else
{
if($showall==”)
{
if( $ispart < 2 && !empty($channeltype) ) $showall = $channeltype;
else $showall = 6;
}
$topQuery = “Select id,typename,typedir,isdefault,defaultname,ispart,namerule2 From `#@__arctype` where reid='{$topid}’ And channeltype='{$showall}’ And ispart<2 And ishidden<>1 “;
}
}
$dsql->Execute(‘t’, $topQuery);
while($row = $dsql->GetArray(‘t’))
{
$row[‘typelink’] = GetTypeUrl($row[‘id’],MfTypedir($row[‘typedir’]),$row[‘isdefault’],$row[‘defaultname’],$row[‘ispart’],$row[‘namerule2’]);
$revalue .= “d.add({$row[‘id’]},-1,'{$row[‘typename’]}’,'{$row[‘typelink’]}’);\n”;
cattreeListSon($row[‘id’], $revalue);
}
$revalue .= “document.write(d);\n”;
$revalue .= ‘</script>’;
$revalue .= ‘</div>’;
return $revalue;
}
function cattreeListSon($id, &$revalue)
{
global $dsql;
$query = “Select id,typename,typedir,isdefault,defaultname,ispart,namerule2 From `#@__arctype` where reid='{$id}’ And ishidden<>1 “;
$dsql->Execute($id, $query);
$thisv = ”;
while($row = $dsql->GetArray($id))
{
$row[‘typelink’] = GetTypeUrl($row[‘id’],MfTypedir($row[‘typedir’]),$row[‘isdefault’],$row[‘defaultname’],$row[‘ispart’],$row[‘namerule2’]);
$revalue .= “d.add({$row[‘id’]},{$id},'{$row[‘typename’]}’,'{$row[‘typelink’]}’)\n”;
cattreeListSon($row[‘id’], $revalue);
}
if($thisv!=”) $revalue .= ” <dd>\n$thisv </dd>\n”;
}
?>
效果:http://www.longwayauto.com/plus/list.php?tid=11
💡 你好!这个修改后会影响HTML静态生成么?
用你的这个方法成功了。。。用动态访问 鼠标点击栏目的下面的背景色包括点开的子类不会错误。。但如果我生成静态那就不行了,虽然还能调出来,但点击某一个栏目却打开的是其他的栏目。。这是为何呀?你知道吗?
Greaat post. І ᴡas checking ccontinuously this blog ɑnd I
am impressed! Extremely ᥙseful information specially
tһe ⅼast part 🙂 I care for sucһ informɑtion much. І was loοking f᧐r thіs ceгtain іnformation ffor a long tіme.
Thank yoou and good luck.
Avoid this as an excuse never to exercise.
Low rise po ang category ng project na to. 10 to 25
floors po ang mid rise.
Cambia mucho la experiencia del instituto con el campus a la experiencia que tendrías con una host family ?
sir when is MM2H opening. Cant wait to move
in
what about the price ? is there à flat t1 ? Thanks for the answer
informative, informative, informative. built up material & inner dimensions are addressed.