I am trying to add my own javascript file that will be called by fckeditor when a person inserts an email link. This javascript will cloak the email address against spammers. I have used it for years, and would like to continue using it after my site is converted to drupal.

I have read that you can add it to the theme template... but I would prefer to add it in a place that is NOT theme dependent. I don't want to have to remember to do the mod everytime I add in a new theme.

Is there another place to add it?

Comments

nevets’s picture

You could write a small module to do it. There may also me a module that implements the same functionality with a filter.

Oblivious-1’s picture

In that vein, if you look at the external links module (http://drupal.org/project/extlink) source code, you'll have a nice head start on figuring out how to do what you want.

--
Erik

ikati’s picture

I appreciate the suggestion, but I don't know php. Although, I've heard it is somewhat similar to perl.. but i don't know if I am in a position to write php code at this point. insert one statement, yes. write a module.. no.

I was looking more for a place in the core drupal that I could put it other than in the theme template.

Thanks, anyway.

Lynne

daadmark’s picture

I think you need to weigh up how much of a hassel it will be to create a module or find an alternate way to do this, considering you don't want to do it in php and don't want to include it in your template.php.

How often are you planning to replace your theme?

ikati’s picture

It is not how often.. but it is a site that will be maintained by different people. which is why I'm converting the site to drupal.

If the theme is changed down the road.. then a 1 line change to add a javascript file might be forgotten. Then email addresses that are entered won't be cloaked. and it won't be apparent until someone starts getting spammed with an address they put on the website. which is too late to do anything about it.

I just thought there was a more common core module where you could add drupal_add_js so that you could specify an JS file in the , so that the javascript JS file would be called no matter what the theme.

but... it looks like this isn't the case. so.. I will add it to the theme template.

daadmark’s picture

Not to keep going on about this, but you will always have a problem like this unless you document everything. Perhaps a document to describe changes required during upgrades or replacements of themes.

Whether you put this in the core files, a custom module or a theme, you will run the risk of it getting missed during a change. Upgrades between drupal releases will usually get rid of any changes you make to the core files.

I would generally think that a theme will be completly changed less than drupal is upgraded.

ikati’s picture

good point.

however, it would be nice if there was a base ".info" file for core drupal, like there is for each theme. so that user modifications that should be applied to all themes would be put in the base .info file.

but.. I think I will define my javascript file in the .info file for the garland theme. at least with the .info file, my modifications for that site are all in one file.

the .info file is described here for anyone else trying to do something similar:
http://drupal.org/node/171205

and the statement to add a personal script is here:
http://drupal.org/node/171205#scripts

Lynne