Try something like this:

class ProductsController extends AppController {
  var $paginate = array(
    'Product' => array(
      'order' => 'RAND()',
      'limit' => 10
    )
  );

  function random() {
    if ($this->Session->check('Products.randomSeed')) {
      $seed = $this->Session->read('Products.randomSeed');
    }
    else {
      $seed = mt_rand();
      $this->Session->write('Products.randomSeed', $seed);
    }
    $this->paginate['Product']['order'] = sprintf('RAND(%d)', $seed);

    // ...
    $products = $this->paginate();
    // ...
  }
}

Should do the trick, might need a bit of tinkering though

On Mar 25, 3:48 pm, Tim <t...@gurske.com> wrote:
> So I have a list of 50 products. I need to display 5 pages of 10
> products each. They need to be in random order so no product has
> priority.
>
> I have everything built with sorting. pagination and other options but
> I'm not sure how to handle this... can it be done?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to