【ACCESS精品源码栏目提醒】:网学会员ACCESS精品源码为您提供ecshop指定分类文章和产品调用_.怺恒._ - 大众科技参考,解决您在ecshop指定分类文章和产品调用_.怺恒._ - 大众科技学习中工作中的难题,参考学习。
最近二次开发了ecshop.接触了php 深入了解了sql.apache 的面纱也揭开了一层.特此记录一下开发时遇到的种种问题.以备后期经验培养.ecshop 代码开源虽然跟shopex 是同一家公司但是ec 还是个没娘的孩子毕竟是免费开源的所以技术开发工作就留给了用户了.大部分用户又以此为收入来源所以....网上一些二次开发的经验这类的都没的研究.先说调用ecshop 数据调用分好几种第一种是js 调用利用后台生成js 代码调用相应的产品.js 调用的好处就是方便实用一句话就可以完成调用而且可以跨站调用有利于推广.但坏处也是多的不能够在主站采用.js 调用一个是数据库读取问题php 在缓存技术上是相当成熟的但是js 调用就没有这个功能所以每次调用都要读取数据库如果调用多了那可能造成网站很卡.还有一个坏处就是js 调用不利于seo.简单来讲就是用js 调用后查看源代码看到的只是一句调用代码而不是产品名称啊价格啊等.所以.如果在主站seo 优化上js 调用是完全可以抛弃的.所以我们要寻找一种利于seo而且能够实现js 调用这些功能的方法.ecshop 给我们提供了smarty所以我们可以做一个声明然后用smarty 来调用这些数据.例如网上已经公布的文章调用方法/ 获得指定栏目最新的文章列表。
access private return array/function index_get_class_articlescat_aid cat_num sql Select article_id titleopen_typecat_idfile_url FROM .GLOBALSecs-tablearticle. Where cat_id .cat_aid.and is_open 1 LIMIT . cat_num res GLOBALSdb-getAllsql arr array foreach res AS idx row arridxid rowarticle_id arridxtitle rowtitle arridxshort_title GLOBALS_CFGarticle_title_length 0 sub_strrowtitleGLOBALS_CFGarticle_title_length : rowtitle arridxcat_name rowcat_name arridxadd_time local_dateGLOBALS_CFGdate_format rowadd_time arridxurl rowopen_type 1 build_uriarticlearrayaid rowarticle_id rowtitle :trimrowfile_url arridxcat_url build_uriarticle_catarrayacid rowcat_id return arr声明后再在需要调用的php 内写入//调用方法smarty-assignclass_articles_4 index_get_class_articles46 //分类调用文章//调用多个就修改传进去的参数以及模板接收的变量其中上面的4 就是文章分类ID其中6 是调用数量//如果在很多页面都加载此分类则把此句放到/include/lib_main.php 下functionassign_templatectype catlist array这样就可以在模板dwt 文件里开始调用了.这样就可以展示出来了.------------------------------------同样产品调用也是这个思路.这里我们调用指定分类下
精品产品列表.首先声明/ 获得cat_id
精品列表。
access private param integer return array/function index_get_cat_id_goods_best_listcat_id num sql Select g.goods_id g.goods_name g.goods_name_styleg.market_price g.shop_price AS org_price g.promote_price . promote_start_date promote_end_date g.goods_briefg.goods_thumb goods_img . g.is_best g.is_new g.is_hot g.is_promote . FROM . GLOBALSecs-tablegoods . AS g . Where g.is_on_sale 1 AND g.is_alone_sale 1 ANDg.is_delete 0 AND g.is_best 1 AND g.cat_id cat_id. LIMIT num res GLOBALSdb-getAllsql goods array foreach res AS idx row goodsidxid rowarticle_id goodsidxid rowgoods_id goodsidxname rowgoods_name goodsidxbrief rowgoods_brief goodsidxbrand_name rowbrand_name goodsidxgoods_style_name add_stylerowgoods_namerowgoods_name_style goodsidxshort_name GLOBALS_CFGgoods_name_length 0 sub_strrowgoods_name GLOBALS_CFGgoods_name_length : rowgoods_name goodsidxshort_style_name add_stylegoodsidxshort_namerowgoods_name_style goodsidxmarket_price price_formatrowmarket_price goodsidxshop_price price_formatrowshop_price goodsidxthumb emptyrowgoods_thumb GLOBALS_CFGno_picture : rowgoods_thumb goodsidxgoods_img emptyrowgoods_img GLOBALS_CFGno_picture : rowgoods_img goodsidxurl build_urigoods arraygid rowgoods_id rowgoods_name return goods声明后用smarty 调用smarty-assigncat_id2_best_goodsindex_get_cat_id_goods_best_list24//2 指分类id,4 指循环次数//如果在很多页面都加载此分类则把此句放到/include/lib_main.php 下functionassign_templatectype catlist array然后就可以在dwt 模板文件里开始调用了具体调用方法有两种因为产品调用要是先js 调用的效果的话就是有H 和V 两种图片价格和文字标题两种.如果是横向调用4 个产品带图片价格等.可以这样写 goods.short_nametruncate:7:true goods.shop_p
上一篇:
重庆邮电大学第二届数据库应用程序大赛方案
下一篇:
bc80e7a0-d1f2-4595-b21d-01a76798e87a