Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How to open a page in colorbox within a (custom) module?
How to open a page in colorbox within a (custom) module?
Comments
Comment #1
frjo CreditAttribution: frjo commentedTake a look at how the Colorbox Node module does it.
http://drupal.org/project/colorbox_node
Comment #2
strr CreditAttribution: strr commentedThank 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);
Comment #3
frjo CreditAttribution: frjo commented