2011-12-03

denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)
[staff profile] denise2011-12-03 05:32 pm

Hooks

This came up in the previous questions post, and it's confusing enough that I thought I'd bring it up to a top-level post: hooks, and what to do if you see something in there that uses one but you can't figure out where the hook is.

LiveJournal uses a lot of hooks to pull ljcom (their equivalent of dw-nonfree) data into livejournal (their equivalent of dw-free) without hardcoding ljcom-specific things into livejournal. You'll see them called like this:

LJ::Hooks::run_hook( "hook_name" );


(sometimes with some other parameters added, or as a variable assignment). Some of them are also used in dreamwidth code: sometimes the hooks that were already defined in the code were useful for our purposes, or we wanted to do the same kind of thing with dw-nonfree code that was being done with ljcom code -- you'll find those in cgi-bin/DW/Hooks. I'd say probably about 90% of the hooks that are tied into the code aren't actually defined in either dw-free or dw-nonfree, though, because we just haven't needed them yet.

So, if you see a hook defined in the code, but you grep the code and nothing turns up for the hook name except the line that calls it -- it's probably an old ljcom hook that we haven't started using yet. You can look at ljcom's cgi-bin/LJ/Hooks directory, if you really are curious about what the hook is meant to do, but since ljcom is not free software, you can't and shouldn't copy the hook directly.