需求:调用一个商城系统里面的产品数据到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’)) {
上一篇:给织梦添加复制文档的功能
下一篇:dede织梦cms系统中如何添加自定义标签方法function
有问题可以加入织梦技术QQ群一起交流学习
本站vip会员 请加入织梦58 VIP②群 PS:加入时备注用户名或昵称
普通注册会员或访客 请加入织梦58 技术交流②群
作者:DEDE58.COM 关注: 时间:2020-06-17 08:36 �
首先声明,只要是我们的vip会员所有源码均可以免费下载,不做任何限制(了解更多)
�本站的源码不会像其它下载站一样植入大量的广告。为了更好的用户体验以后坚持不打水印
�本站只提供精品织梦源码,源码在于可用,不在多!!希望在这里找到你合适的。
�本站提供的整站织梦程序,均带数据及演示地址。可以在任一源码详情页查看演示地址
�本站所有资源(包括源码、模板、素材、特效等)仅供学习与参考,请勿用于商业用途。
�如有其他问题,请加网站客服QQ(970003436)进行交流。
相关: