Hi !

I'd love an option to have slides appear in random order instead of always in the same fixed order.

This would allow for sidebar block rotating banners to not always show the same slides every time one changes pages (since they always restart on slide one on each page load).

Thanks

Franck Horlaville
TAM Software

Comments

tamsoftware’s picture

There is the 'random' option on jquery.cycle, so apparently one needs to:

- add a checkbox for it in the admin section
- save the setting appropriately
- pass it on to the cycle plugin

Anything else ?

I'm diving into it.

Cheers,

Franck Horlaville
TAM Software

tamsoftware’s picture

Status: Active » Needs review

Done !

Here is what I have added, I'll create a patch asap

file rotating_banner.classes.inc

  public static function getDefaultSettings($key = NULL) {
    //@todo: add variables here.
    static $defaults = array(
      'controls' => 'buttons',
      'prev_next' => 0,
      'width' => '',
      'height' => '',
      'fluid' => TRUE,
      'cycle' => array(
        'fx' => 'scrollDown',
        'timeout' => 8000,
        'fit' => 0,
        'random' => 0,  /*added this line at line #178*/
      ),
    );

file rotating_banner.module

/*line 359 insert the following statement*/

 $rb_form['banner_settings']['cycle']['random'] = array(
    '#type' => 'radios',
    '#title' => t('Randomize'),
    '#options' => array(
      '1' => 'The slides will appear in random order.',
      '0' => 'The slides will show in the specified order.',
    ),  
    '#default_value' => $settings['cycle']['random'],
  );

/*end of add, just before the end of form statement */

  return $form;
tamsoftware’s picture

StatusFileSize
new2.04 KB

Here's the patch file

tamsoftware’s picture

Request for comments - better a radio button or a checkbox for Randomize ? Thanks

tamsoftware’s picture

Update: I see that my patch includes the patch for fixing z-index error which I submitted in http://drupal.org/node/1209712

BramVanroy’s picture

Thanks again! Hey TAM Software, thanks a lot! This works perfectly! This should be a standard functionality!

ultimateboy’s picture

This is great. I'm just not a fan of the radios titles (and the field name) I'd do something like this instead, changing the field name to "order" and having "default" and "random" options.

$rb_form['banner_settings']['cycle']['order'] = array(
  '#type' => 'radios',
  '#title' => t('Slide order'),
  '#options' => array(
    '0' => 'Default',
    '1' => 'Random',
  ),
  '#default_value' => $settings['cycle']['random'],
);
tamsoftware’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
niek_kloots’s picture

It works with rotating_banner-7.x-2.x-dev.
But also see my post #3 on https://www.drupal.org/node/2159665

tamsoftware’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev