Drupal 6: best practice for changing contributed module's JavaScript

牧云@^-^@ 提交于 2019-12-06 16:48:37

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!