解决专题页产品分类顺序错乱问题
大家都知道在ecshop里面有一个专题功能,后台促销管理-专题管理里面可以添加专题广告描述,并且可以加产品分类作为产品展示.
可是默认有一个问题就是当调用产品分类的时候会错乱,也就是顺序不是按分类正常排序来的,下面ecshop模板堂给出修改方案来解决这个错误.
打开topic.php,找到如下代码:
- $cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . '-' . $_CFG['lang'] . '-' . $topic_id));
- if (!$smarty->is_cached($templates, $cache_id))
改成:
- $cache_id = sprintf('%X', crc32($_SESSION['user_rank'] . '-' . $_CFG['lang'] . '-' . $topic_id));
- if (1)
找到最下面一段:
-
- assign_template();
- $position = assign_ur_here();
- $smarty->assign('page_title', $position['title']);
- $smarty->assign('ur_here', $position['ur_here'] . '> ' . $topic['title']);
- $smarty->assign('show_marketprice', $_CFG['show_marketprice']);
- $smarty->assign('sort_goods_arr', $sort_goods_arr);
- $smarty->assign('topic', $topic);
- $smarty->assign('keywords', $topic['keywords']);
- $smarty->assign('description', $topic['description']);
- $smarty->assign('title_pic', $topic['title_pic']);
- $smarty->assign('base_style', '#' . $topic['base_style']);
- $template_file = emptyempty($topic['template']) ? 'topic.dwt' : $topic['template'];
- }
-
- $smarty->display($templates, $cache_id);
改成:
- foreach($arr as $key1=>$val1)
- {
-
- foreach($sort_goods_arr as $key2=>$val2)
- {
- if($key1==$key2)
- {
-
- $sort_goods_arr_2[$key2]=$val2;
- }
- }
- }
-
-
-
- assign_template();
- $position = assign_ur_here();
- $smarty->assign('page_title', $position['title']);
- $smarty->assign('ur_here', $position['ur_here'] . '> ' . $topic['title']);
- $smarty->assign('show_marketprice', $_CFG['show_marketprice']);
- $smarty->assign('sort_goods_arr', $sort_goods_arr_2);
- $smarty->assign('topic', $topic);
- $smarty->assign('keywords', $topic['keywords']);
- $smarty->assign('description', $topic['description']);
- $smarty->assign('title_pic', $topic['title_pic']);
- $smarty->assign('base_style', '#' . $topic['base_style']);
- $template_file = emptyempty($topic['template']) ? 'topic.dwt' : $topic['template'];
- }
-
- $smarty->display($templates);