![]() |
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? |
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:
|
Re: Limiting the number of featured products displayed and randomising
That works a charm. Excellent! Thank you very much Spinyman :)
|
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?
|
Re: Limiting the number of featured products displayed and randomising
Quote:
Code:
shuffle($products); |
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. |
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... |
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); ?> |
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. |
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 |
All times are GMT -8. The time now is 05:02 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.