| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Limiting the number of featured products displayed and randomising | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Limiting the number of featured products displayed and randomising
Hi,
I would like to limit the number of featured products displayed on a subcategory and then randomise this limit so that different featured products (from that category) are displayed per refresh. For example, I would like only 6 featured products to show but have a different 6 featured products displaying on each refresh. Any ideas?
__________________
:: Wardworth Ltd :: X-Cart 4.1.8 |
|||||||||
#2
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
Quote:
Hi, open "featured_products.php" and add 2 lines of code Quote:
Quote:
it will show 6 random products with the pages to other featured products (if more exists). If this variant doesn't meen your wish try this one: put this code Quote:
Quote:
__________________
Regards, SpinyMan X-Cart Templates Store - http://www.x-cart-customization.com/shop/ X-Cart Customization Services - http://www.x-cart-customization.com/ |
|||||||||
|
#3
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
That works a charm. Excellent! Thank you very much Spinyman
__________________
:: Wardworth Ltd :: X-Cart 4.1.8 |
|||||||||
#4
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
lovely code. but what if i only want to show one page and remove subsequent page links?
__________________
Yamiya Yam http://www.yamiya.com.my --------------------------------------- X-Cart Gold v4.1.8 (UNIX) |
|||||||||
#5
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
Quote:
Code:
__________________
Regards, SpinyMan X-Cart Templates Store - http://www.x-cart-customization.com/shop/ X-Cart Customization Services - http://www.x-cart-customization.com/ |
|||||||||
#6
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
Code is not working.
http://www.yamiya.com.my/ I am trying to get rid of Result pages: 1 2 3 > in Featured Products only.
__________________
Yamiya Yam http://www.yamiya.com.my --------------------------------------- X-Cart Gold v4.1.8 (UNIX) |
|||||||||
#7
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
Quote:
Could u gimme a code of your featured_products.php? I think u made a little mistake there (maybe u put the code in wrong place)... because everything must working well...
__________________
Regards, SpinyMan X-Cart Templates Store - http://www.x-cart-customization.com/shop/ X-Cart Customization Services - http://www.x-cart-customization.com/ |
|||||||||
#8
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }
# # Select from featured products table # $user_account['membershipid'] = !empty($user_account['membershipid'])?$user_account['membershipid']:0; $old_search_data = $search_data["products"]; $old_mode = $mode; $old_page = $page; $search_data["products"] = array(); $search_data["products"]["forsale"] = "Y"; $search_data["products"]["sort_condition"] = "$sql_tbl[featured_products].product_order"; $search_data["products"]['_']['inner_joins']['featured_products'] = array( "on" => "$sql_tbl[products].productid=$sql_tbl[featured_products].productid AND $sql_tbl[featured_products].avail='Y' AND $sql_tbl[featured_products].categoryid='".intval($cat)."'" ); $REQUEST_METHOD = "GET"; $mode = "search"; include $xcart_dir."/include/search.php"; $search_data["products"] = $old_search_data; x_session_save("search_data"); $mode = $old_mode; $page = $old_page; unset($old_search_data, $old_mode, $old_page); if (!empty($active_modules["Subscriptions"])) { include_once $xcart_dir."/modules/Subscriptions/subscription.php"; } $smarty->clear_assign("products"); $smarty->assign("navigation_script","home.php?cat=$cat&sor t=$sort&sort_direction=$sort_direction"); #Randomize featured products shuffle($products); array_splice($products,$config["Appearance"]["products_per_page"]); $smarty->assign("f_products",$products); $search_data = ''; $products = array(); unset($search_data, $products); ?>
__________________
Yamiya Yam http://www.yamiya.com.my --------------------------------------- X-Cart Gold v4.1.8 (UNIX) |
|||||||||
#9
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
Hi,
The code is working fine, but I'm getting the following warnings - Warning: shuffle() expects parameter 1 to be array, null given in featured_products.php on line 91 Warning: array_splice(): The first argument should be an array in featured_products.php on line 92 anyone know why? I'm not that php literate.
__________________
:: Wardworth Ltd :: X-Cart 4.1.8 |
|||||||||
#10
|
|||||||||
|
|||||||||
Re: Limiting the number of featured products displayed and randomising
Quote:
Hello Wardworth, It does this only if there is no featured products for the category. Solution ? - Check every category for featured products (and select featured products for the categories that do not have them) - Add an "if" line of code...that I am not able even to imagine, being quite a rookie in PHP. Anybody wanting to help us on this one ? Cheers, Philippe
__________________
X-Cart Gold 4.1.9 - 4.2.0 - 4.2.2 Telafirma: Dynamic Images, Narrow by Manufacturer, Product Page manufacturer, Static Pages Categories, Multicolumn Recommends Firetank Software: Featured Products, Feed Manager, Newest Products, Sitemap Pro, Marketing Manager Xcartmods: Ultimate Minicart, 4 Level Horizontal (and Vcal) Flyout BCSE: Reviews Edit, Multiple Upselling MagenticOne: Tag Cloud, Store Manager, Custom Data Feed Websitecm: Xnews, Xnews SEO, CDSEO Pro Jon Langevin: Gone With The Wind ! |
|||||||||
|
|||
X-Cart forums © 2001-2020
|