Home > Backend Development > PHP Tutorial > Solution to display all categories in ecshop classification tree_PHP tutorial

Solution to display all categories in ecshop classification tree_PHP tutorial

WBOY
Release: 2016-07-13 10:56:06
Original
1088 people have browsed it

ecshop classification tree displays solutions for all categories. Friends in need can refer to this article.

The solution is as follows:
For example, in goods.php,

 代码如下 复制代码
 $smarty->assign('categories',         get_categories_tree());  // 分类树

About line 128. Just look for it


Will

The code is as follows
 代码如下 复制代码
$smarty->assign('categories', get_categories_tree($goods['cat_id']));
Copy code

$smarty->assign('categories' , get_categories_tree($goods['cat_id']));
 代码如下 复制代码
$smarty->assign('categories', get_categories_tree());

changed to

The main thing is to remove goods['cat_id'] or the obtained ID!

Afterwards clear the cache and check the frontend to see if it has changed

 代码如下 复制代码
    if ($cat_id > 0)
    {
        $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'";
        $parent_id = $GLOBALS['db']->getOne($sql);
    }
    else
    {
        $parent_id = 0;
    }
Note: Only half of the solution has been solved here. You still need to perform the same operation in category.php so that all categories are displayed on the category page.


An easier way is to modify the get_categories_tree function, which was reminded by the water god. Modify as follows:

The code is as follows Copy code
if ($cat_id > 0)
{ $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'";

$parent_id = $GLOBALS['db']->getOne($sql);

} {           $parent_id = 0; } Find this judgment statement, comment it out, and add // Add settings to read out all categories $parent_id = 0;
http://www.bkjia.com/PHPjc/632193.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632193.htmlTechArticleecshop classification tree displays all classification solutions. Friends in need can refer to this article. The solution is as follows: For example, in goods.php, the code is as follows Copy the code $smarty-assig...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template