destoon7.0任意模块根据itemid调取content内容

分类栏目:destoon实战

189

在自定义函数文件中 api\extend.func.php 中加入以下代码

function getContentbyId($moduleid,$itemid,$split=1){ global $db; $content_table = content_table($moduleid, $itemid,$split); $t = $db->get_one("select content from {$content_table} where itemid=$itemid"); return $t['content']; }


函数说明:


//根据文章id获取分表内容

//第一个参数$moduleid  如果是在非当前模块使用需要写死,如在站点首页: {getContentbyId(21,$t[itemid])}

//如果是当前模块,可以直接用$moduleid,如在资讯页面: {getContentbyId($moduleid,$t[itemid])}

//如果不分表的话可以多传一个0,{getContentbyId($moduleid,$t[itemid],0)},

//当前模块还可以直接{getContentbyId($moduleid,$t[itemid],$MOD['split'])},

//不传第三个参数默认为分表模式(dt后台模块设置里可以开启,可以起到优化的作用)