WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Last Items randomise products
  • Print
Pages: [1]   Go Down

Author Topic: Last Items randomise products  (Read 8355 times)

daydreamer

  • Guest
Last Items randomise products
« on: August 27, 2010, 08:03:30 PM »
I know Last Items shows the latest added products first, is there anyway to make them randomise each time the page loads.
Thanks
Logged

freeSbee

  • Guest
Re: Last Items randomise products
« Reply #1 on: August 27, 2010, 11:07:45 PM »
Hi Daydreamer

Test this:
Replace about line 113 of the include.php file
Code: [Select]
$query_items = $database->query("SELECT item_id, title, price, link, description, main_image FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY modified_when DESC LIMIT ".$num_items);
by
Code: [Select]
$query_items = $database->query("SELECT item_id, title, price, link, description, main_image FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY RAND() DESC LIMIT ".$num_items);

Be aware that this can take a large amount of processing time for table of more than 500 rows.

Regards Christoph
Logged

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: Last Items randomise products
« Reply #2 on: August 27, 2010, 11:31:52 PM »
I belive that the replaced line would display random X rows from items (ordered descending by any DB field name), and not LAST X rows

Try to adjust your code to
Code: [Select]
$query_items = $database->query("SELECT item_id, title, price, link, description, main_image FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY modified_when DESC LIMIT ".$num_items);
while($row = $query_items->fetchRow())
{
// Display and style your block here
$results2= "item id: ".$row['item_id']." title: ".$row['price']." link: ".$row['link']." description: ".$row['description']." image: ".$row['main_image'];

//THIS FUNCTION WILL SHUFFLE ORDER OF YOUR LAST ROWS SELECTED FROM DB
shuffle($results2);

// display array of items..
echo $results2;

Christoph may help you find the line where to insert shuffle function..

cheers
« Last Edit: August 27, 2010, 11:51:13 PM by crnogorac081 »
Logged
Web developer

daydreamer

  • Guest
Re: Last Items randomise products
« Reply #3 on: August 28, 2010, 11:47:52 AM »
Hi guys,

Many thanks for the help the first line seems to work fine, thanks Christoph

@crnogorac081

I replaced with you your to try that and it shows syntax error but I'm not sure why as I'm not a coder

Many Thanks
Nick

Logged

daydreamer

  • Guest
Re: Last Items randomise products
« Reply #4 on: August 28, 2010, 11:53:02 AM »
Just as an after thought could'nt this be added to bakery as another addon module "Show Random Products"

Regards
Nick
Logged

snark

  • Guest
Re: Last Items randomise products
« Reply #5 on: September 04, 2010, 02:54:27 PM »
What would be very nice is THE option to mark an item to be displayed

Something like THE groups option in news so that you can decide what to display in an anyitem sort of snipper
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Last Items randomise products
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2