search
Homephp教程php手册ECSHOP在商品详细页面上获取该商品的顶级分类id和名称,ecshop顶级

ECSHOP在商品详细页面上获取该商品的顶级分类id和名称,ecshop顶级

在 goods.php 文件,

找到 $smarty->assign('goods', $goods); 
在它上面增加下面代码:

方法一:

<span>$cat_arr</span> = get_parent_cats(<span>$goods</span>['cat_id'<span>]);
</span><span>foreach</span> (<span>$cat_arr</span> <span>AS</span> <span>$val</span><span>) <br />{
  </span><span>$goods</span>['topcat_id']=<span>$val</span>['cat_id'<span>];
</span><span>  $goods</span>['topcat_name']=<span>$val</span>['cat_name'<span>];
}</span>

方法二:

<span>$cat_arr</span> = get_parent_cats(<span>$goods</span>['cat_id'<span>]);
</span><span>$topcat_arr</span> = <span>end</span>(<span>$cat_arr</span><span>);
</span><span>$goods</span>['topcat_id']=<span>$topcat_arr</span>['cat_id'<span>];
</span><span>$goods</span>['topcat_name']=<span>$topcat_arr</span>['cat_name'];

然后,在商品详情模板文件 goods.dwt 中调用如下:

顶级分类id:{$goods.topcat_id}
顶级分类名称name:{$goods.topcat_name}

ecshop中首页获取了一个分类的cat_id,怎调用它的以及它子类的商品?

$children = get_children($cat_id); 获得指定分类同级的所有分类以及该分类下的子分类

/**
* 获得分类下的商品
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)

看看category.php 是怎么用的
 

ecshop怎调用指定id的顶级分类以及子分类名称

首页调用指定分类下子分类方法
模板首页一般都有分楼层显示的分类商品,每个楼层右上角会有该分类下小分类排列显示的:
以往有些模板这里都是静态显示的,需要客户手动依次修改,现在模板中心告诉您怎样修改成动态调用,只需修改一个id即可。
1.打开您的文件根目录下 includes/lib_goods.php 文件,在最后一行加入一个方法:
function get_parent_id_tree($parent_id)
{
$three_c_arr = array();
$sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$parent_id' AND is_show = 1 ";
if ($GLOBALS['db']->getOne($sql))
{
$child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' .
'FROM ' . $GLOBALS['ecs']->table('category') .
"WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC ";
$res = $GLOBALS['db']->getAll($child_sql);
foreach ($res AS $row)
{
if ($row['is_show'])
$three_c_arr[$row['cat_id']]['id'] = $row['cat_id'];
$three_c_arr[$row['cat_id']]['name'] = $row['cat_name'];
$three_c_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
}
}
return $three_c_arr;
}

2. 在模板文件里调用,如首页index.dwt中 :

$this->assign('thiscid1', get_parent_id_tree(17));//调用父级分类的下级分类
?>


{$list.name}


括号里的“17”为分类id,按照您的网站商品分类修改......余下全文>>
 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ecshop是什么构架ecshop是什么构架Feb 23, 2023 am 09:32 AM

ecshop是“B2C”构架;ecshop是一款B2C独立网店系统,适合企业及个人快速构建个性化网上商店;该系统是基于PHP语言及MYSQL数据库构架开发的跨平台开源程序。

ecshop文章排序方法有哪些ecshop文章排序方法有哪些Jun 16, 2023 am 11:30 AM

ecshop文章排序方法:1、按照发布时间排序,可以通过修改文章的发布时间来控制文章在列表中的排列顺序;2、按照点击量排序,可以通过安装“文章点击排行榜”插件来实现该排序功能,该插件可以统计文章的点击量;3、按照评论数排序,可以通过安装“文章评论排行榜”插件来实现该排序功能,该插件可以统计文章的评论数;4、按照相关度排序,可以通过安装“搜索排名”插件来实现该排序功能。

ecshop有什么特点ecshop有什么特点Feb 13, 2023 am 09:43 AM

特点:1、开源系统,具有灵活性、可定制性和高拓展性;2、支持自主二次开发;3、丰富的模版、插件;4、行业适应能力强;5、避免被软件商束缚;6、更强的可靠性、稳定性;7、移动H5框架升级,基于VUE全面换代,更加灵活开放;8、多级返佣功能,支持二维码、海报等推广方式,无限裂变发展分销商;8、管理端视觉交互全面焕新,UI简洁美观,操作体验升级;9、支持PHP7.2,性能提升一倍。

ecshop是什么程序ecshop是什么程序Feb 16, 2023 am 10:38 AM

ECShop是一款B2C独立网店系统,是基于PHP语言及MYSQL数据库构架开发的跨平台开源程序,适合企业及个人快速构建个性化网上商店。ecshop商城系统的特点:1、支持自主二次开发;2、丰富的模版、插件;3、行业适应能力强;4、避免被软件商束缚;5、更强的可靠性、稳定性。

ecshop是什么模式ecshop是什么模式Feb 22, 2023 am 09:37 AM

ecshop是B2C模式。ECShop是一款B2C独立网店系统,适合企业及个人快速构建个性化网上商店。B2C是指电子商务的一种模式,也是直接面向消费者销售产品和服务商业的零售模式;B2C电子商务的付款方式是货到付款与网上支付相结合,而大多数企业的配送选择物流外包方式以节约运营成本。

Ecshop商品管理进阶:学习如何增加字段Ecshop商品管理进阶:学习如何增加字段Mar 12, 2024 pm 02:06 PM

Ecshop商品管理进阶:学习如何增加字段,需要具体代码示例在使用Ecshop进行商品管理时,经常会遇到需要增加一些自定义字段的情况,以满足特定的需求。通过增加字段,可以实现更加精确的商品管理和更好的用户体验。本文将介绍如何在Ecshop中增加字段,并提供具体的代码示例。首先,我们需要明确增加字段的需求。例如,我们需要在商品详情页增加一个“生产日期”字段,以

怎么去掉ecshop底部版权怎么去掉ecshop底部版权Aug 08, 2023 pm 02:42 PM

去掉ecshop底部版权的方法:1、修改模板文件,具体位置为:themes/your_theme目录,在该目录下找到footer.html文件,用文本编辑器打开,找到包含版权信息的代码段,将其删除或注释掉。保存文件并关闭即可;2、使用插件,登录后台,点击插件管理,搜索底部版权等相关关键词,选择一个适合的插件安装并启用它即可;3、购买主题,在ECShop的官方网站购买等等。

ecshop怎么取消配送方式ecshop怎么取消配送方式Mar 03, 2023 am 09:56 AM

ecshop取消配送方式的方法:1、找到并打开“flow.dwt”文件,然后删除“<!--{if $total.real_goods_count neq 0}-->...<!-- {/if} -->”代码;2、将”js/shopping_flow.js“中的”checkOrderForm(frm)“改为”if (document.getElementById(...)“即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function