Hi.

In our sites we use Greybox 5.5 (because it's one of the few that can render HTML pages in an overlay) so we wished to use your brilliant gallery (in both senses of the phrase :P) with greybox.

Made the following adjustments:

line 119
    '#options' => array(
      'lightbox' => t('Lightbox'),
+     'greybox' => t('Greybox'),
      'thickbox' => t('Thickbox'),
      'none' => t('None'),
    ),


line 250
                         switch( $overbrowser ) {
                           case 'thickbox':
                             $result .= ' class="thickbox"';
                             $result .= ' rel="img_' . $setname . '"';
                             #$attributes['class'] = $link_class;
                             #$attributes['rel'] = 'img_' . ($node->nid? $node->nid: time()); // 'insert' has no $node->nid
                             break;
                           case 'lightbox':
                             $result .= ' rel="lightbox[' . $setname . ']"';
                             #$attributes['rel'] = 'lightbox[' . ($node->nid? $node->nid: time()) . ']'; // 'insert' has no $node->nid
                             break;
+                          case 'greybox':
+                            $result .= ' rel="gb_imageset[' . $setname . ']"';
+                            break;
                           default:
                             break;
                         }

It's a minor change but a functional one :P

Thanks for your time and effort

Remon.

Comments

vacilando’s picture

Well, good idea - but it did not work with
rel="gb_imageset[' . $setname . ']"

When I used
class="greybox"

What do you think?

vacilando’s picture

I mean it worked when I used
class="greybox"

What's the difference? Did you test your solution and was it working?

rmpel’s picture

Well, good idea - but it did not work with
rel="gb_imageset[' . $setname . ']"

I it worked when I used
class="greybox"

What's the difference? Did you test your solution and was it working?

The difference is: the first is used by Greybox 5.5, the second is based on greybox redux

And ofcourse I tested my solution :P

Another tip for the programmer; when building your options list, do it like this:

$options = array();
if (module_exists('lightbox')) {
  $options['lightbox'] = t('Lightbox');
}
if (module_exists('thickbox')) {
  $options['thickbox'] = t('Thickbox');
}
if (module_exists('greybox_5_5')) {
  $options['greybox'] = t('Greybox 5.5');
}
if (module_exists('greybox')) {
  $options['greybox_redux'] = t('Greybox Redux');
}

// and then in the form def:
  '#options' => $options,

Whereas the greybox_5_5 module is built by yours truly and the greybox redux is available on drupal.org.

Greybox redux requires the following:

                           case 'greybox':
                             $result .= ' class="'. variable_get('greybox_class_text', "greybox") .'"';
                             break;
rmpel’s picture

And though I'm not here to tell you what to do, i would suggest building a hook system;
Instead of defining the different overlays hardcoded, do a module_invoke to get the overlays.

what I mean is;
1st party: brilliant gallery module
2nd party: lightbox module
2nd party: greybox redux module

Now, create extra modules that depend on brilliant gallery AND lightbox that implements the hook you call in BG.
So in BG you do

$options = module_invoke('bg', 'list');

to get the options entries, then something like

$function = $chosen_overlay .'_bg';
$result .= $function('tag', $setname);

to get the specific tag.

The module that implements the hook (lets call it the bg_with_greybox module) does;

// implements hook_bg for brilliant gallery module
function bg_with_greybox_bg($op = 'list', $vars = null) {
  switch($op) {
    case 'list':
      return array('bg_with_greybox' => t('Greybox Redux');
    break;
    case 'tag':
      return ' class="'. variable_get('greybox_class_text', 'greybox'). '"';
    break;
  }
}

this way a user cannot activate an overlay (s)he hasnt installed (the dependencies line in the info file makes sure of that)
the options will show only available overlays
3rd party can create extra modules for new overlays without having to alter the original code :)

so for the Greybox 5.5 module I created it would be:

// implements hook_bg for brilliant gallery module
function bg_with_greybox_5_5_bg($op = 'list', $vars = null) {
  switch($op) {
    case 'list':
      return array('bg_with_greybox_5_5' => t('Greybox 5.5');
    break;
    case 'tag':
      return ' rel="gb_imageset['. $vars .']"';
    break;
  }
}

ofcourse, I would, myself, implement this hook in a new version of the module greybox_5_5 to make it brilliant gallery aware :)

Anyways, just thinking aloud here. This is how I would do it, by no means the only way and also absolutely not obligatory :P

rmpel’s picture

whoops.... module_invoke in the example here should be module_invoke_all. my bad :P

Remon.

vacilando’s picture

Excellent tips, thanks. Remon. I'll get back to you on those asap.

But I am still failing to understand one crucial item in this discussion. Where is the greybox_5_5 Drupal module you have been talking about?

Tomas

rmpel’s picture

I sent it to your e-mail, or rather, I replied in my mail client to the notification of your contact-form-input and sent you the module.

jan.n’s picture

Status: Active » Closed (fixed)

Changed status to closed due to 10 weeks without any activity