


ECSHOP gets the top category id and name of the product on the product details page, ecshop top_PHP tutorial
ECSHOP gets the top-level category id and name of the product on the product details page, ecshop top-level
is in the goods.php file,
Find $smarty->assign('goods', $goods);
Add the following code above it:
Method 1:
<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>
Method 2:
<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'];
Then, call the following in the product details template file goods.dwt:
Top category id: {$goods.topcat_id}
Top category name: {$goods.topcat_name}
$children = get_children($cat_id); Get all categories of the same level as the specified category and subcategories under this category
/**
* Get products under the category
*
* @access public
* @param string $children
* @return array
*/
function category_get_goods($children, $brand, $min, $max, $ext, $size , $page, $sort, $order)
See how category.php is used
The homepage calls the subcategory method under the specified category
The template homepage generally has classified products displayed by floors. In the upper right corner of each floor, there will be small categories arranged and displayed under the category:
In the past, some templates were here For static display, customers need to manually modify it one by one. Now the template center will tell you how to modify it to dynamic call. You only need to modify an ID.
1. Open the includes/lib_goods.php file in your file root directory and add a method in the last line:
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. Call in the template file, such as in the homepage index.dwt:
$this-> ;assign('thiscid1', get_parent_id_tree(17));//Call the subordinate category of the parent category
?>
{$list.name}
The "17" in brackets is the category id, modify it according to the product category of your website... The rest of the full text >>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



ecshop is a "B2C" architecture; ecshop is a B2C independent online store system, suitable for enterprises and individuals to quickly build personalized online stores; the system is a cross-platform open source program developed based on PHP language and MYSQL database architecture.

How to sort ecshop articles: 1. Sort by publication time, you can control the order of articles in the list by modifying the publication time of the article; 2. Sort by clicks, you can achieve this sorting by installing the "Article Click Ranking" plug-in Function, this plug-in can count the number of clicks on articles; 3. Sort by the number of comments, you can implement this sorting function by installing the "Article Comment Ranking" plug-in, which can count the number of comments on articles; 4. Sort by relevance, This sorting function can be achieved by installing the "Search Ranking" plug-in.

Features: 1. Open source system with flexibility, customizability and high scalability; 2. Support independent secondary development; 3. Rich templates and plug-ins; 4. Strong industry adaptability; 5. Avoid being constrained by software vendors; 6. Stronger reliability and stability; 7. Mobile H5 framework upgrade, based on VUE comprehensive replacement, more flexible and open; 8. Multi-level rebate function, supporting QR codes, posters and other promotion methods, unlimited fission development of distributors ; 8. The visual interaction of the management terminal is completely renewed, the UI is simple and beautiful, and the operating experience is upgraded; 9. Supports PHP7.2, and the performance is doubled.

Ecshop Product Management Advanced: Learn how to add fields, you need specific code examples. When using Ecshop for product management, you often encounter situations where you need to add some custom fields to meet specific needs. By adding fields, more precise product management and better user experience can be achieved. This article will introduce how to add fields in Ecshop and provide specific code examples. First, we need to clarify the need to add fields. For example, we need to add a "production date" field to the product details page to

ECShop is a B2C independent online store system. It is a cross-platform open source program developed based on PHP language and MYSQL database architecture. It is suitable for enterprises and individuals to quickly build personalized online stores. The characteristics of the ecshop mall system: 1. Support independent secondary development; 2. Rich templates and plug-ins; 3. Strong industry adaptability; 4. Avoid being constrained by software vendors; 5. Stronger reliability and stability.

ecshop is a B2C model. ECShop is a B2C independent online store system, suitable for enterprises and individuals to quickly build personalized online stores. B2C refers to a model of e-commerce, and it is also a retail model that sells products and services directly to consumers; the payment method of B2C e-commerce is a combination of cash on delivery and online payment, and most companies choose logistics outsourcing for delivery. to save operating costs.

Method to remove the copyright at the bottom of ecshop: 1. Modify the template file, the specific location is: themes/your_theme directory, find the footer.html file in this directory, open it with a text editor, find the code segment containing the copyright information, delete it or Comment out. Just save the file and close it; 2. To use the plug-in, log in to the backend, click plug-in management, search for copyright and other related keywords at the bottom, select a suitable plug-in to install and enable it; 3. To purchase a theme, purchase it on the official website of ECShop etc.

How to cancel the shipping method in ecshop: 1. Find and open the "flow.dwt" file, and then delete "<!--{if $total.real_goods_count neq 0}-->...<!-- {/if} - ->" code; 2. Change "checkOrderForm(frm)" in "js/shopping_flow.js" to "if (document.getElementById(...)".
