While Plupload Integration for 6.x currently has a modest feature set, I feel this patch does a lot to allow developers to do a lot more with the module without actually having to build out the feature set of the plupload module "core".
Why the presave hook?
-The presave hook allows a developer to create logic-based, or settings based, way of filling out other node fields, taxonomy, etc
Why the postsave hook?
-The $node object in the post save hook contains a full picture of the node, (including the nid) This hook allows a developer to do *something* that that node after its creation. (something like, create a node reference to the new node from an existing node)
Why does this have to be here--why not use the nodeapi?
-I want to only do these things to the nodes created through the plupload tool, I want my content administrators to be able to create the same type of node. through the node/add form, and not have all of this other *magic* stuff happen.
Thanks Loads!
Comment | File | Size | Author |
---|---|---|---|
#11 | plupload-hooks-914242-11.patch | 611 bytes | vordude |
#10 | plupload-add-node-hooks.patch | 613 bytes | justintime |
plupload-add-node-hooks.patch | 637 bytes | vordude |
Comments
Comment #1
gregglesThis looks great to me!
I'd like to add more parameters to each call, perhaps a $options as an array or something, so that we can send in more data.
My dream is that at /file-plupload we could add parameters like /file-plupload?terms[]=1,5,60?gids[]=99 And then a module would add taxonomy terms 1, 5, 60 and OG could add the group 99. To do that cleanly we should add hooks like you suggest and give them some more data.
Comment #2
gregglesComment #3
vordude CreditAttribution: vordude commentedWhat data does this $options array hold by default? If you want to pull the data out of the url, it could be done in the other module inside of the basic hook, no?
Comment #4
gregglesI don't think so.
There's the /file-plupload?tids[]=1,2,3 URL. That has the parameters in it.
But the actual URL that gets the files is just "plupload-pernode" without any parameters.
What we need to do is add the tids into the headers
I don't expect your patch to fix all that, but we should at least build these hooks with the ability to handle extra $options.
Comment #5
justintime CreditAttribution: justintime commentedJust a note that you can use nodeapi to do operations on just plupload added nodes by adding this to the presave op:
The approaches above are more clean, but my approach is a workaround until such a feature is implemented.
Comment #6
justintime CreditAttribution: justintime commentedI'm thinking that with the inclusion of #919482: create ability to assign parameters in the url, implement taxonomy term as an example, we don't need these hooks any longer. Here's an example of how you can achieve what Vordude wants without any hooks. If you're using the included file-plupload page, just link to it like so: 'file-plupload?drupal_pluploaded=1'
If you're calling the plupload_upload_page function within your module, pass it this:
Now, in nodeapi (prepare and save for your pre and post hooks), you can simply say:
We can certainly implement hooks if need be, but I think at this point it just is duplicating existing features. Thoughts?
Comment #7
vordude CreditAttribution: vordude commentedPlease don't write the idea off yet.
I'll soon be working on an extension module for plupload that does other "stuff" (cck widget/form element) with the tool, extending the initial basic 'core' implementation.
I can see that for this to work, plupload will need to stay flexible in how data needs to be passed around, I haven't had the chance to flesh this out in its entirety.
You're right, the Node API, can handle this (at this point). But IMHO the hooks provide a cleaner interface for developers to do what they like before and after the node is created.
Comment #8
gregglesI think more hooks are better than fewer. If we add in the $options that is created in #919482: create ability to assign parameters in the url, implement taxonomy term as an example then I think this patch is ready to go.
Comment #9
justintime CreditAttribution: justintime commentedHadn't thought of the sub-module thing - agree. I'll commit #919482: create ability to assign parameters in the url, implement taxonomy term as an example today if you want to reroll your patch.
Comment #10
justintime CreditAttribution: justintime commentedOK, I'll bite. Here's a re-rolled patch with the options passed in.
Comment #11
vordude CreditAttribution: vordude commentedActually when I rolled this to begin with, I'm pretty sure the &$node is wrong.
If you're going to pass it by reference it should be done in the function definition not here.
Pretty sure php will puke warnings if you have it in the module_implements...
Comment #12
justintime CreditAttribution: justintime commentedHeh, you're right. That'll teach me to create patches when on Nyquil :)
AFAIK, call-time pass by reference is a warning in PHP <= 5.2, but an error in 5.3+.
Have you actually tested the patch? I'd have to code up a dummy hook to test it.
Comment #13
justintime CreditAttribution: justintime commentedCommitted to 6.x dev: #914252 by vordude, greggles, justintime: Adding presave/postsave hooks to Plupload
Comment #14
justintime CreditAttribution: justintime commentedForgot to mark as fixed.
Comment #16
brunorios1 CreditAttribution: brunorios1 commentedsubscribing...
Comment #17
gregglesbrunorios1 - why are you subscribing to an issue that is "closed - fixed."
If it's broken or you need something please say what it is.
Comment #18
brunorios1 CreditAttribution: brunorios1 commentedsorry, was a mistake...