飞龙博客

feilong.org 前端开发教程

zencart display featured products by some category

飞龙更新于 2010-08-23 08:30 加入书签 CTRL+D 有 106 个朋友来过

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.

飞龙初发:
2010-08-23 08:30
本文更新网址:
https://feilong.org/zencart-display-featured-products-by-category

所在目录: 建站程序

新作:

旧文:

  • html css js
  • angular react vue
  • flutter python