飞龙博客

飞龙博客 飞龙在天

zencart display featured products by some category

feilong.org 修订于2010-08-23 08:30:41 314 次浏览

When studying zencart temmplate,you will confront the problem,how to display featured products by some category.If you want to display or not to display featured products by or in some category,feilong tell you my answer just this post:zencart-display-featured-products-by-category

1. first to display featured products needs these files,they are in your zencart temmplate or languages or modules

1) tpl_index_default.php: where you want to display featured products.
2) tpl_modules_featured_products.php: a featured products area for you.
3) tpl_columnar_display.php: generating tabular output title and content .
4) featured_products.php: this is the key php file featured products content .

2. open 'featured_products.php', add some code which is highlighted in red

// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$featured_products_query = '';
$display_limit = '';

$where_str = " AND p.master_categories_id = 13 ";//add by feilong.org choose a master category
//$where_str .= " AND p.master_categories_id != 64 ";//add by feilong.org NOT choose a master category

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
$featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id
from (" . TABLE_PRODUCTS . " p
left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
where p.products_id = f.products_id
and p.products_id = pd.products_id
and p.products_status = 1 and f.status = 1
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" . $where_str;//feilong.org choose  category
} else {
....(other codes )

3. if you want to display another featured post area,feilong tell you here

1)in tpl_index_default.php ,display another featured post area,notice code which is highlighted in yellow

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the first Featured Products Center Box
*/
$feature='one';
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the other Featured Products Center Box
*/
$feature='two';
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>

2)in featured_products.php,according the $featured category value,give a categories id.add code:

if ($feature=='one'){
$where_str = " AND p.master_categories_id = 13 ";//add by feilong.org choose a category
} else {
$where_str = " AND p.master_categories_id = 64 ";//add by feilong.org choose a category
}

ok,use you head,you can do it too.

更新网址:https://feilong.org/zencart-display-featured-products-by-category
最初发布:20100823 08:30:41 feilong.org 于广州

加入收藏夹,查看更方便。

所在分类: 建站程序

新作:

旧文:

blog money bui 教程 echarts 教程 eclipse 教程 html css 教程 IT趋势 js 教程 json 教程 mysql 教程 nodejs npm 教程 onblog SQLite 教程 tutorials vscode 教程 wap网站 winpe启动盘 wordpress 主机推荐 书法 前端开发 博客 名企名网 国学 域名注册 常用软件 建站程序 操作系统 教程 数码 无线上网 日记 电子商务 电脑笔记本 网站 网站优化 网站开发 网站推广 网站策划 网络 虚拟现实 默认