91豆麻精品91久久久久久,中文在线资源,国产精品女视频,yw.139尤物在线精品视频

?
  歡迎訪問全國企業(yè)網(wǎng)站設(shè)計NO.1網(wǎng)站開發(fā)商平臺 付款方式
主頁 > 網(wǎng)站建設(shè) > 建站知識 > dedecms添加自定義標簽顯示非dede表數(shù)據(jù)

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

POST TIME:2020-10-09


需求:調(diào)用一個商城系統(tǒng)里面的產(chǎn)品數(shù)據(jù)到dedecms文章頁,希望對需要類似需求的人有所幫助
 
功能實現(xiàn):為了不用垮數(shù)據(jù)庫查詢,dedecms安裝到商城系統(tǒng)數(shù)據(jù)庫里面
 
下面是實現(xiàn)的代碼(請根據(jù)自己的環(huá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.dede58.com/', ps.`AcStr`, '-view-', p.`ID`, '.html') AS url,
 
CONCAT('http://www.dede58.com/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}
 
 
 

需求:調(diào)用一個商城系統(tǒng)里面的產(chǎn)品數(shù)據(jù)到dedecms文章頁,希望對需要類似需求的人有所幫助
 
功能實現(xiàn):為了不用垮數(shù)據(jù)庫查詢,dedecms安裝到商城系統(tǒng)數(shù)據(jù)庫里面
 
下面是實現(xiàn)的代碼(請根據(jù)自己的環(huá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.dede58.com/', ps.`AcStr`, '-view-', p.`ID`, '.html') AS url,
 
CONCAT('http://www.dede58.com/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'))
 
{
? 主站蜘蛛池模板: 鄂温| 丹阳市| 盘山县| 高邑县| 蒲江县| 巫山县| 崇阳县| 阳曲县| 黄平县| 长白| 阜平县| 师宗县| 阿勒泰市| 昌黎县| 朝阳县| 紫云| 衢州市| 肇州县| 灵寿县| 弋阳县| 社会| 湛江市| 太保市| 九江县| 沿河| 双牌县| 元谋县| 佛学| 环江| 阿巴嘎旗| 金昌市| 额尔古纳市| 禹城市| 云安县| 锡林郭勒盟| 屏东县| 兰西县| 凌海市| 荥经县| 进贤县| 疏勒县|