您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop首页怎么显示积分商城的商品信息内容

张准辰2023-12-04Ecshop商城教程已有人查阅

导读1)、首先打开 index.php 文件在最末尾增加下面函数,注意千万不要写到 “?>” 的外面去,要加在“?>”的前面。

1)、首先打开 index.php 文件在最末尾增加下面函数,注意千万不要写到 “?>” 的外面去,要加在“?>”的前面。

/**
* 获得积分商城热门商品
*
* @param   int      $limit        列出条数
* @param   int      $ishot       是否只显示热销
* @return array
*/
function index_get_exchange($limit=3,$ishot=0)
{
    /* 获得热门积分商品列表 */
$sql_ishot=$ishot ? " AND eg.is_hot=1 " : "";
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, eg.exchange_integral, ' .
' g.goods_type,g.goods_brief, g.goods_thumb, g.goods_img, eg.is_hot ' .
' FROM ' . $GLOBALS['ecs']->table('exchange_goods') . ' AS eg LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = eg.goods_id  ' .
' WHERE eg.is_exchange = 1 AND g.is_delete = 0 '. $sql_ishot .'  limit '.$limit;
$res = $GLOBALS['db']->getAll($sql);
    $arr = array();
   foreach($res AS $idx => $row)
    {
$arr[$idx]['name']              = $row['goods_name'];
$arr[$idx]['goods_brief']       = $row['goods_brief'];
$arr[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$idx]['exchange_integral'] = $row['exchange_integral'];
$arr[$idx]['type']              = $row['goods_type'];
$arr[$idx]['goods_thumb']       = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$idx]['goods_img']         = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$idx]['url']               = build_uri('exchange_goods', array('gid'=>$row['goods_id']), $row['goods_name']);
    }
    return $arr;
}

然后继续在 index.php 文件中 找到

$smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告

在它下边另起一行增加如下代码

$smarty->assign('goods_exchange_list',index_get_exchange(6,0));  //积分商城

如果你想只显示热销的积分商品,只需将上面代码稍作修改即可

$smarty->assign('goods_exchange_list',index_get_exchange(6,1));  //积分商城

2)、下面继续修改模板文件 themes/default/index.dwt
在你想显示积分商城商品的地方,加入下面代码段

<!--积分商城列表-->
<div class="box">
 <div class="box_1">
  <h3><span><a href="/exchange.php" class="f6">积分商城</a></span></h3>
    <div class="centerPadd">
    <div class="clearfix goodsBox" style="border:none;">
      <!--{foreach name=goods_exchange_list from=$goods_exchange_list item=exchange_goods}-->
      <div class="goodsItem">
  <a href="{$exchange_goods.url}" target="_blank"><img src="{$exchange_goods.goods_thumb}" alt="{$exchange_goods.goods_name}" class="goodsimg" /></a><br />
   <p><a href="{$exchange_goods.url}" target="_blank">
  <!-- {if $exchange_goods.goods_style_name} -->
  <font class="f3">{$exchange_goods.goods_style_name}</font><br />
  <!-- {else} -->
  <font class="f3">{$exchange_goods.goods_name}</font><br />
  <!-- {/if} -->
  </a>
  </p>
{$lang.exchange_integral}<font class="price">{$exchange_goods.exchange_integral}</font>
        </div>
      <!--{/foreach}-->
      <div class="more"><a href="/exchange.php"><img src="images/more.gif" /></a></div>
    </div>
    </div>
 </div>
</div>
<div class="blank5"></div>

3)、到后台清除下缓存,然后刷新首页就能看到效果了

本文标签:

很赞哦! ()

相关源码

  • (PC+WAP)红色户外岗亭钢结构岗亭pbootcms网站模板为钢结构岗亭、户外设施企业打造的高端响应式营销门户,基于PbootCMS开源内核深度开发,采用HTML5自适应架构,实现PC与移动端数据实时同步展示。查看源码
  • (自适应响应式)APP应用程序软件介绍落地页源码免费下载该模板为营销技术从业者设计,提供专业的内容展示平台。采用响应式布局,适配软件介绍、APP推广等营销场景,通过可视化后台可快速搭建符合行业特性的展示网站。查看源码
  • (自适应)英文电子芯片电子元件网站pbootcms模板下载基于PbootCMS内核开发的电子元件类企业专用模板,采用响应式设计技术,适配电子元器件、集成电路、半导体等行业的品牌展示与技术文档发布需求。前端布局针对芯片参数表格与产品规格书展示进行深度优化。查看源码
  • (自适应)大气网络公司工作室个人作品展示网站模板免费下载基于PbootCMS内核开发的响应式网站模板,为网络技术服务类企业打造,具备高度可定制性。通过简洁现代的设计语言展现企业专业形象,后台数据实时同步机制确保多终端内容一致性,查看源码
  • (PC+WAP)中英双语户外用品帐篷装备pbootcms网站模板下载这款基于PbootCMS开发的中英文双语模板专为户外装备行业设计,适配PC和移动设备。模板采用现代化设计风格,突出户外产品的功能性和实用性,帮助企业建立专业的国际化展示平台。查看源码
  • (自适应)大型农业机械设备水稻玉米收割机网站pbootcms源码下载本模板基于PbootCMS内核开发,为农业机械设备制造与销售企业设计,特别适合水稻玉米收割机、拖拉机、播种机等农用机械展示。模板充分考虑了农机行业的特性,从产品展示到技术参数,从作业案例到售后服务查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐