2

I need to theme my lightbox. I can see the HTML generated by the JavaScript code in lightbox.js, but I cannot overwrite that file, or I will lose my changes when I update the module. Is there any better way to override a theme output?

apaderno
  • 28,547
  • 16
  • 75
  • 90
Evanss
  • 23,390
  • 94
  • 282
  • 505

2 Answers2

1

You didn't report for which Drupal version you are interested; the answer I am giving is valid for Drupal 6, but few things would change for Drupal 7.

Lightbox2 uses a template file for its output. If you create a custom module that implements hook_theme_registry_alter() to use a different template file, then you can use a template file that uses a JavaScript file you wrote.

apaderno
  • 28,547
  • 16
  • 75
  • 90
0

can you not theme it just by changing the CSS?

In your theme's .info file you can override the module's css and/or js and then you copy the css or js file from the module into your own theme folder, (every theme should have a .info, if not create one) - this means you don't touch the actual contrib modules files

Drupal will then use the one from your theme, which you can edit to your hearts content, and if you do hit problems you just remove the entry from the .info file and it will then go back to using the original module filea.

I haven't done it for JS but I believe the process is the same as for CSS and here is a snippet of what's in my .info file - btw I think once you use this method of overriding you have to declare the default style.css too

stylesheets[all][] = style.css
stylesheets[all][] = lightbox.css

Update:

It's only possible to use the .info file to override JS in D7, but there is module JSAlter which might help with D6

clairesuzy
  • 27,296
  • 8
  • 54
  • 52
  • The theming I need to do means I cant just override the CSS. I need to actually change the html the js creates. As this is part of the lightbox module I dont think I can do this by loading different js. Thanks – Evanss Apr 09 '11 at 11:42
  • I think you can override your JS in the same way, via the .info file.. then you could rewrite it inside your theme without a module update affecting it – clairesuzy Apr 09 '11 at 11:44
  • sorry I misinformed you, it's only possible to treat JS this way in D7, however there's a module [JSAlter](http://drupal.org/project/jsalter) which does it D6 – clairesuzy Apr 09 '11 at 11:48
  • 1
    Ok, maybe I could 'hijack' the js file. It wont necessarily be update proof as an update could change the original js file, and then maybe my override wont work with the module anymore. Unless theirs another way I think for simplicity ill just stick with my hacky method and hope the lightbox module isn't updated too often. Thanks – Evanss Apr 09 '11 at 12:10