校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 網(wǎng)站建設(shè) > 建站知識(shí) > dedecms添加自定義標(biāo)簽顯示非dede表數(shù)據(jù)

dedecms添加自定義標(biāo)簽顯示非dede表數(shù)據(jù)

POST TIME:2017-11-12 23:42

需求:調(diào)用一個(gè)商城系統(tǒng)里面的產(chǎn)品數(shù)據(jù)到dedecms文章頁,希望對需要類似需求的人有所幫助
功能實(shí)現(xiàn):為了不用垮數(shù)據(jù)庫查詢,dedecms安裝到商城系統(tǒng)數(shù)據(jù)庫里面
下面是實(shí)現(xiàn)的代碼(請根據(jù)自己的環(huán)境進(jìn)行修改)
include/taglib/hongyungoods.lib.php
文件內(nèi)容如下:
if(!defined('DEDEINC')) exit('Request Error!');
functionlib_hongyungoods($ctag, $refObj)
{
global$dsql, $envs, $cfg_cmsurl;
//屬性處理
$attlist="row|6,titlelen|0,tid|0";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
//只在指定欄目顯示
if($tid>0 $tid!= $envs['typeid']) return'';
if( !$dsql->IsTable("sl_products") ) return'沒安裝產(chǎn)品模塊';
$innertext= $ctag->GetInnerText();
if(trim($innertext)=='') $innertext= GetSysTemplets("hongyungoods.htm");
//@todo 智能條件
$where= 1;
$limit= 5;
$ctp= newDedeTagParse();
$ctp->SetNameSpace('field', '[', ']');
$ret= '';
$query= "SELECT p.`Name` AS title,
CONCAT('http://www.genban.org/', ps.`AcStr`, '-view-', p.`ID`, '.html') AS url,
CONCAT('http://www.genban.org/uploadfile/s/', p.`Images`) AS img
FROM `sl_products` AS p
LEFT JOIN `sl_products_sort` AS ps ON p.`SID` = ps.`ID`
WHERE " . $where . "ORDER BY RAND() LIMIT " . $limit;
$dsql->Execute('me',$query);
while($rs= $dsql->GetArray('me'))
{
$rs['title'] = 0 == $titlelen?$rs['title']:cn_substr($rs['title'], $titlelen);
$ctp->LoadSource($innertext);
foreach($ctp->CTags as$tagid=>$ctag) {
if(!empty($rs[strtolower($ctag->GetName())])) {
$ctp->Assign($tagid,$rs[$ctag->GetName()]);
}
}
$ret.= $ctp->GetResult();
}
return$ret;
}
?>
調(diào)用頁面使用:
{dede:hongyungoods}
[field:title/]
{/dede:hongyungoods}


收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 连州市| 阿巴嘎旗| 广西| 阿拉尔市| 隆尧县| 通许县| 昌吉市| 资源县| 麻江县| 渝中区| 日照市| 阜宁县| 双桥区| 盐城市| 麻城市| 紫金县| 贵德县| 青海省| 文水县| 宜黄县| 鸡西市| 滦平县| 类乌齐县| 凤山市| 湄潭县| 绥芬河市| 山东省| 盐津县| 北海市| 安康市| 伊川县| 蒲江县| 灌云县| 勐海县| 鄯善县| 阿巴嘎旗| 农安县| 淮阳县| 石城县| 丰原市| 循化|