![让DedeCms分类信息模型支持Digg功能,第1张 让DedeCms分类信息模型支持Digg功能,第1张](/aiimages/%E8%AE%A9DedeCms%E5%88%86%E7%B1%BB%E4%BF%A1%E6%81%AF%E6%A8%A1%E5%9E%8B%E6%94%AF%E6%8C%81Digg%E5%8A%9F%E8%83%BD.png)
让DedeCms分类信息
模型支持Digg功能
用DedeCms做的
模板需要在分类信息里支持Digg功能,但是原程序里,只能对系统模型和自由模型Digg,即使用@#__archives当作主表的模型。而DedeCms里,分类信息模型是作为独立模型设置的。
这个功能的实现,只需要
修改一个文件,即/plus/Digg_ajax.php:
$maintable = ‘dede_archives’;原程序的这行决定了不能为独立update。
可以修改为:
$row=$dsql->GetOne(”Select id,channel from `dede_arctiny` where id=$id”);
//改取arctiny表,取得该id的文章所属的模型
if($row['channel']==-8)
{
//为分类信息模型时,更新的表为addoninfos,其它类推
$maintable=’dede_addoninfos’;
$idname=’aid’;
//由于独立模型id不同,所以需要一个变量来存id名称,该id为aid
}
else
{
$maintable = ‘dede_archives’;
$idname=’id’;
}
然后把下面用到的三条SQL语句中的id修改为$idname,即:
$dsql->ExecuteNoneQuery(”Update `$maintable` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=”.time().” where $idname=$id”);
$dsql->ExecuteNoneQuery(”Update `$maintable` set scores = scores – {$cfg_caicai_sub},badpost=badpost+1,lastpost=”.time().” where $idname=$id”);
$row = $dsql->GetOne(”Select goodpost,badpost,scores From `$maintable` where $idname=$id “);
经过上述的修改,再为article_infos.htm模板增加Digg的模板,可以从文章模板复制,就可以为分类信息等独立模型增加Digg功能了。
评论列表(0条)