Hey guys,

I'm working on dropping in a DHTML editor for my drupal site and I need to add some javascript to the head of the page where you create a node (story). Not having much luck finding the right part in the code - any pointers?

I'm currently using the polder module/theme

cheers,
neko

Comments

neko’s picture

got it running smooth-as - here's a quick summary

Part 1
story.module->story_form()
calls form_dhtml_editor() in common.inc
which calls form_textarea but modifes the $description variable with some dhtml editor specific JS.

Part 2
we also need some js in the head tag, to get that we add
dhtml_editor_header() to common.inc (has the required js), then theme_head() looks like this:

function theme_head($main = 0) {
  $head = module_invoke_all("head", $main);
  // SM 2/11/2003 12:44PM -- for the dhtml editor
  array_push($head, dhtml_editor_header());
  return implode($head, "n");
}

that means theme.inc has to now:

 include_once "includes/common.inc";

Part 3
The reason for doing the above is to provide the same function to admin.php, which has the following echo in the appropriate place:

echo(dhtml_editor_header());

testing now, when I get it working I'll let you know Future plans could be setting this up as a generic module that you can configure in the admin interface, and choose what node-types use it and for which fields. Or something, haven't really thought much on it.

neko

moshe weitzman’s picture

any module can add custom javascript, CSS, etc. to the HEAD section using the head hook. no need to patch theme.inc

sounds interesting. looking forward to seeing your invention.

phildog’s picture

I'm getting the dreaded:
You are not authorized to access this page.

When trying to reach "the head hook" link from above. Is this still the preferred method for adding your own javascript to the page's HEAD? If so, how can I learn how to use it?

joe lombardo’s picture

Text entry usability is a big issue. I'm excited to hear that you are trying to find a solution for drupal sites.

Thanks!

Joe Lombardo | joe@familytimes.com | My Blog

neko’s picture

Screenshot

Still working on ironing it out for different browser versions, but all seems good so far!

Currently it's not a module or anything, it's just hacked into drupal for the body field of story nodes, but If I have time I might do so and release (anyone else feel free to step in, but I want to learn how to write Drupal modules anyway).

neko