I've a question about how to customize drupal modules avoiding hacks.
Let's say I've downloaded Lightbox2 module and I want to change the javascript file to display differently my lightbox.
At the moment I'm modifying the Lightbox2 module, so I cannot update it anymore, so I know it is not the best practice.
I was wondering if I can customize the javascript file of this module with a hook, and how.
Thanks
To alter just the JS, you shouldn't need to hack the module at all. Instead, you can use the theme system to alter what scripts are sent to the page.
In your template.php preprocess page:
$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);
I suggest you then copy across the lightbox js to new path and make your alterations there, rather than starting from scratch.
Some modules provide their own hooks and theme functions which you can override directly, so it might be worth poking around a bit in the lightbox module for those too.