Hi, there would be great to upgrade the usage of "Deactivate Colorbox on specific pages". I'm using colorbox in only one content type, and it's just annoying to exclude all pages when there should be something to allow colorbox only on specific pages. (like blocks should be perfect)

thanks for all.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lsolesen’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

So exactly what are you suggesting. Could you create a screen mockup or even a patch to include this?

FAAREIA’s picture

FileSize
52.05 KB

I don't know how to code, but here is an screenshot. The main idea is to easily load colorbox in pages that needs it. In the current "Deactivate Colorbox on specific pages" you need to list all pages except the ones that needs it. (usually you need to update this list since you create new taxonomies, or even custom paths)

Thanks for your time.
Greetings

inventlogic’s picture

Agreed this should be a feature. Activate on following pages or Deactivate on following pages.

I have added the following to my admin theme template.php. It adds a check-box at the bottom of the admin/config/media/colorbox settings form under ADVANCED SETTINGS. If you tick the check-box the pages listed will have the colorbox javascript included. Everything else is automatically excluded.

function seven_form_colorbox_admin_settings_alter(&$form, $form_state, $form_id)  {

        $colorbox_include_form = variable_get('colorbox_include_only');

         if ( $colorbox_include_form ) {

        $form['colorbox_advanced_settings']['colorbox_include_only'] = array(
                '#type' => 'checkbox',
                '#default_value' => '1',
                '#title' => t('Tick to include colorbox only on the pages listed above.'),
            );
         }
         else {
         $form['colorbox_advanced_settings']['colorbox_include_only'] = array(
                 '#type' => 'checkbox',
                 '#title' => t('Tick to include colorbox only on the pages listed above.'),
             );

         }
}

I then changed the following code in colorbox.module

// Code from the block_list funtion in block.module.
  $path = drupal_get_path_alias($_GET['q']);
  $colorbox_pages = variable_get('colorbox_pages', "admin*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*");
  // Compare with the internal and path alias (if any).
  $page_match = drupal_match_path($path, $colorbox_pages);
  if ($path != $_GET['q']) {
    $page_match = $page_match || drupal_match_path($_GET['q'], $colorbox_pages);
  }

  return !$page_match;
}

To the following which includes a test for the include only checkbox set to true.

  // Code from the block_list funtion in block.module.
  $path = drupal_get_path_alias($_GET['q']);
  $colorbox_pages = variable_get('colorbox_pages', "admin*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit");
  // Compare with the internal and path alias (if any).
  $page_match = drupal_match_path($path, $colorbox_pages);
  if ($path != $_GET['q']) {
    $page_match = $page_match || drupal_match_path($_GET['q'], $colorbox_pages);
  }

  $colorbox_include = variable_get('colorbox_include_only');
  if ( $colorbox_include ) {
  return $page_match;
}
else {
  return !$page_match;
}
}

Seems to work by only including colorbox on the listed pages. Anyone else adding this to their template.php please test before using.

Can this be added to the next version of colorbox please?

inventlogic’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
FileSize
1.54 KB

Attached is a patch against the Master branch to include the check-box.

inventlogic’s picture

Same patch file renamed with the issue number

frjo’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.95 KB

Please test my revised patch for this functionality. I have made it lock just like it does for blocks in Drupal core.

inventlogic’s picture

Thanks. Applied patch against 7.x-1.x-dev and works.

frjo’s picture

Assigned: Unassigned » frjo
Status: Needs review » Fixed

Thanks for testing! Committed to 7-dev.

FAAREIA’s picture

Excellent work. Many thanks for this patch, it works perfectly.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Jason_K’s picture

I'm still using Druapl 6, and don't know enough about coding to rewrite this for Colorbox 6.x, but it would be so useful. Anyone know of an equivalent patch for 6.x? Thanks.