Drupal 6: Best Practice for Modifying Added JavaScript Module

I have a question on how to configure drupal modules avoiding hacks.

Say I downloaded the Lightbox2 module and I want to modify the javascript file to display my lightbox differently.

I am currently modifying the Lightbox2 module, so I can no longer update it, so I know that this is not the best practice.

I was wondering if I can configure the javascript file of this module with a hook and how.

thank

+1
source share
1 answer

To change only JS, you do not need to hack the module at all. Instead, you can use the system to change which scripts are sent to the page.

template.php:

 $scripts = drupal_add_js();
 unset($scripts['module']['whatever/the/path/is/lightbox.js']);
 $scripts['module']['new/js/path/lightbox.js'] = array('preprocess' => 1, 'cache' => 1);
 $variables['scripts'] = drupal_get_js('header', $scripts);

js , .

, , Lightbox.

+4

Source: https://habr.com/ru/post/1750602/


All Articles