Hi david , i have downloaded the new featuredExternal.php and the new distribution but im unable to get it to work how i want (worked ok on the old distribution)
i want to add some code to featuredExternal.php , to show random items but to select one merchant first and to only show 20 items (3 items per line).
is there a modded featuredExternal.php that is already available??
cheers , yeh just tried that but for some reason nothing is displayed.
the featuredExternal.php in that post as it is works but when i change the code as you have said nothing is displayed
Hi Jonny,
Ah - it could be that you have a field registered for the merchant name instead of it existing within the feeds table. Try this as an alternative:
$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$result);
$merchant = $result[0]["merchant"];
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY RAND() LIMIT 20";
Keep an eye on performance however, if selecting a random merchant from the products table is too slow we'll look at other ways to achieve it...
Cheers,
David.
thats great , many thanks , all working , its been bugging me all day , new it would be something simple :)
performance should be fine as its a niche site and only a few hundred items max
cheers for the help
Hi Jonny,
Based on the featuredExternal.php for the latest distribution from this post, look for the following code at line 64:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` WHERE name NOT LIKE '%/%' ORDER BY sequence";
...and REPLACE with:
$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."feeds` ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$result);
$merchant = $result[0]["merchant"];
$sql = "SELECT name,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY RAND() LIMIT 20";
Hope this helps!
Cheers,
David.