By geohelper on
I've got "mycustom.module" that contains all my hacks but is there a hook for capturing a specific CCK type's add/edit form submission?
I'd like to trigger a function to run upon each add/edit of the CCK content type.
Is is the hook nodeapi or submit... and then how do I specific the specific CCK type?
Thanks -- Matt
Comments
*** i'm interested in this too
***bookmarking.
geohelper...
i've got a related question to your post..
you mention that you have a "mycustom.module" that contains all of your hacks.
could you say more about this and how you implemented it?
i get the feeling it's similar to what i want to do. by that i mean that your mycustom.module isn't a standalone functional module. it probably is just a placeholder where you put a whole bunch of stuff, often unrelated, but stored in one place.
am i right about this?
i'm noticing that i'm starting to insert a lot of php snippets in pages/blocks/etc.. which means i've got code spread out all over the place. that's going to make it harder to maintain, update, backup and reuse on other projects. ideally i'd like to be able to put all of that unrelated code (mostly php blocks that would be encapsulated in function calls for reuse as well as custom function calls for debugging etc) in one spot (e.g. a module). then i could just either call the function from the blocks/nodes etc.. now my code is all in one spot (of course my calls are still distributed but the meat of the code is isolated).
i'm not sure if i need to do anything to such a module other than just drop my functions in it and turn it on to make the functions available to blocks/nodes etc? i mean are there any hooks that need to be supplied? the module won't be a node so it doesn't need all the form_alter, menu hooks etc...
any help/thoughts appreciated (or a skeleton file if you have one)
thanks
I do something similar.
I do something similar. Basically, I use that "mycustom.module" as an advanced "template.php". Any function you put in there can be called at any time.
So essentially, you could keep building up your custom module of functions and port it around to each install you do, so you'll always have your own custom functions at your finger tips.
portable toolbox / template.php / hooks
I'm working on something similar and am running into a situation where I don't wanna make custom content types in a module (partly because I'm not smart enough, partly because I don't need full control over the content type's actions), but would like to be able to perform an action every time a certain type of content is added to a site. This post seems to say the content_update hook function is not the place to do this. Anybody have any ideas?
Ceardach, I think I get your approach, but WHEN do you call your function from your custom module? I'd rather not run my tests on every page or every call to hook_nodeapi. I'd like to call a function every time a "content showing" (CCK type) is added and am unsure of where to put that code. If I include a subform in the CCK type, content_update is accessed, with no subform in CCK type, content_update seems to not be accessed.
Any suggestions appreciated! Thanks.
--
Joe Golden
GreenMountainLinux.Com : People, Ideas, Connections
centralized hacking module
Yeah, I use the custom modue for centralized hacking, specifically...
This is used for a lot of stuff on http://ridertech.com
Here's a start.
I'm just starting to figure this out myself, but here's what I have so far. . .
The transcripts from one of the recent Drupal Dojo lessons got me started. Those turned me onto the Devel module. Once installed and turned on, the Devel module adds tabs to your nodes that display information about the node itself. From that, I was able to find the type name for my CCK data type, in this case "content_source_proposal".
Another Drupal Dojo session included information about nodeapi. The only function I've created so far is a nodeapi function, which I've included in my own module, which I called "source.module".
Once enabled, the "Function fired!" message displays when a new "Source proposal" is submitted. Obviously, there isn't much to my function yet, but it's a start and I think it addresses your initial question.
Now, I'm interested in finding out how to differentiate between the initial submission and subsequent editing. I want my function to only run on the initial submission and not on edits. Any ideas?
answered my own question
Upon further inspection of the nodeapi documentation, I realized I was on the right track by putting what I needed in the "submit" part of the switch and ignorring the "update" section.
Dojo on NodeAPI
For future reference: there is an awesome Dojo lesson on NodeAPI that describes exactly how to do this:
http://groups.drupal.org/node/2403