On the product details page, ECSHOP obtains the top-level Category id and name of the product. On the product details page, ECSHOP obtains the top-level Category id and name of the product. in the php file, find $ smarty-assign (goods, $ goods). add the following code on it: ECSHOP obtains the top-level Category id and name of the product on the product details page.
In the goods. php file,
Find $ smarty-> assign ('Goods ', $ goods );
Add the following code to it:
Method 1:
$cat_arr = get_parent_cats($goods['cat_id']);foreach ($cat_arr AS $val)
{ $goods['topcat_id']=$val['cat_id']; $goods['topcat_name']=$val['cat_name'];}
Method 2:
$cat_arr = get_parent_cats($goods['cat_id']);$topcat_arr = end($cat_arr);$goods['topcat_id']=$topcat_arr['cat_id'];$goods['topcat_name']=$topcat_arr['cat_name'];
Then, in the product details template file goods. dwt, call the following:
Top-level Category id: {$ goods. topcat_id}
Top-level category name: {$ goods. topcat_name}
In ecshop, the home page obtains the cat_id of a category. how do I call it and its sub-category products?
$ Children = get_children ($ cat_id); obtain all classes of the specified category at the same level and subcategories under the specified category
/**
* Obtain products under a category
*
* @ Access public
* @ Param string $ children
* @ Return array
*/
Function category_get_goods ($ children, $ brand, $ min, $ max, $ ext, $ size, $ page, $ sort, $ order)
Let's see how category. php is used.
How does ecshop call the top-level category and subcategory name of a specified id?
The homepage calls the subcategory method under a specified category.
Generally, the template home page contains classified items displayed on different floors. Each floor is displayed in the upper-right corner of the page:
In the past, some templates were displayed statically. you need to manually modify them in sequence. now the template center tells you how to change them to dynamic calling. you only need to modify one id.
1. open the pludes/lib_goods.php file in the root directory of your file, 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 it in the template file, such as in index. dwt of the homepage:
$ This-> assign ('thisciid1', get_parent_id_tree (17); // calls the subcategory of the parent category
?>
{$ List. name} </A>
The "17" in the brackets is the category id, which is modified according to the category of your website Products ...... the remaining full text>
In the goods. php file, locate $ smarty-assign ('Goods ', $ goods). add the following code on it :...