How to open a page in colorbox within a (custom) module?

Comments

frjo’s picture

Category: task » support

Take a look at how the Colorbox Node module does it.

http://drupal.org/project/colorbox_node

strr’s picture

Thank you,
i found the following part in the colorbox_node.module but its not working yet. My case is much more simple as i want all parameters and the target url to be hardcoded. Could someone please modify that for my case.

drupal_add_library('system', 'drupal.ajax');

$params = array();
$params['inline'] = TRUE;
$params['href'] = 'http://veryimportantproducts.com/cart';
$params['width'] = '800';
$params['height'] = '600';

$params = json_encode($params);

$javascript = '

(function ($) { $(document).ready(function() { var params = '. $params .'; $.fn.colorbox($.extend({}, Drupal.settings.colorbox, params)); }); // We need to clear out our html just in case there is // a video with autoplay. $(document).bind("cbox_closed", function() { $("#cboxNode").html(""); }); })(jQuery);

';
$commands[] = ajax_command_html('#cboxNodeJS', $javascript);

// Render our commands out to the browser.
return array('#type' => 'ajax', '#commands' => $commands);

frjo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)