星联网络专注帝国CMS二次功能插件开发-精品网站模板站长代码素材

  • 最近更新
  • 模板:33
  • 记录:12641|
  • 插件:52|
  • 工具:4|
  • 代码:8|
  • 评论:0

dedecms添加自定义标签显示非dede表数据

前言

本文主要讲解《dedecms添加自定义标签显示非dede表数据》的详细内容


需求:调用一个商城系统里面的产品数据到dedecms文章页,希望对需要类似需求的人有所帮助 功能实现:为了不用垮数据库查询,dedecms安装到商城系统数据库里面 下面是实现的代码(请根据自己的环境进行修改) include/taglib/hongyungoods.lib.php 文件内容如下: 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'没安装产品模块'; $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; } ?> 调用页面使用: {dede:hongyungoods} [field:title/] {/dede:hongyungoods}
需求:调用一个商城系统里面的产品数据到dedecms文章页,希望对需要类似需求的人有所帮助 功能实现:为了不用垮数据库查询,dedecms安装到商城系统数据库里面 下面是实现的代码(请根据自己的环境进行修改) include/taglib/hongyungoods.lib.php 文件内容如下: 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'没安装产品模块'; $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')) {

本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。

本文地址:http://www.xlkjgs.com/notes/web/6521.html

以上内容由本站整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

星联网络

星联网络是中国最具实战的互联网创业者的知识服务商,这里有互联网行业动态,网络推广,SEO优化,SEM优化,ESC配置,行业经验分型,互联网项目,微信营销、淘宝客赚钱、新媒体营销、京东运营、跨境电商等众多互联网营销知识分享

站长运营站长必备网站运营之道才能长久发展