inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Jan 30, 2015 15:05:16 GMT -8
EDIT: I've added my own submit button for the tree to set the key which works OK, but the below request would make things easier/cleaner. Hi Everyone, I'm currently writing a plugin and using the post set_on( hook, [object_id], [value] ) but I need ( would like ) this to work for when someone edits a post. In the API it says: So I suppose this is a request for an extra hook, eg: post_edit or does someone know something I don't about setting the post key on edit. I didn't want to get all hacky if some other easier way already exists. Just in case it matters, though I don't think it does, it's a family tree plugin, entered from the posting page but I want to have the option of editing the tree from the edit page. Demo ( which may or may not be working depending on if I'm playing about with it at the time and I've broken something! ) is here: pebbleplugins.proboards.com/thread/72/family-tree-testingCheers, Pebble. ------------------------------------------------------------------------------------ EDIT2:While I'm here as the above I've made a work around for the moment.... Is it possible to set a post key using 'thread_new' ? If someone is creating a new thread then I want to set the post key when they submit the new thread. I've tried using pb.plugin.key('familytree').set_on('post_new', tree ); but it doesn't work for the new thread post.... ------------------------------------------------------------------------------------
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jan 31, 2015 13:56:03 GMT -8
I took a look at the source to come up with the above hack for limiting the plugin to staff only and noticed that it used a set_on hook not listed in the API reference: key.set_on(' thread_edit', fieldHash); According to the API: " Right now this is limited to 'thread_new' and 'post_new'." The All about Plugin Keys thread lists even more hooks: Plugin Key EventsWe offer a few different event bindings that you can use to change plugin key data when certain actions happen. These events are: - thread_new - When a thread is created
- post_new - When a post is made
- post_quick_reply - When a post is made using the quick reply
- conversation_new - When a conversation is created
- message_new - When a reply to a conversation is made
Using these events, you can set a plugin key's data only when the event listed has occurred. Here is sample code on how to bind to a plugin key event: <script> pb.plugin.key('example_thread_key').set_on('thread_new', 'Hello world'); </script>
Hmm, not sure how the API got wrong, but yeah, there look to be plugin key hooks on creating conversations and messages, and creating/updating threads and posts. I'll add a task in to update the API, but honestly at this point it's likelier that that task will languish until the bigger task that will add far more comprehensive hooks for set_on. The thread_new hook is especially useful since it allows setting a key for a thread at the same time the thread is created (thus alleviating the problem of object_id being unknown since not yet created -- the chicken or the egg scenario)
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Jan 31, 2015 17:13:01 GMT -8
It's late at night so I'll take another read in the morning! From the above, logic would say there is a hidden post_edit hook already in there. ( which I'll try tomorrow ) The thread_new hook, I've tried to use but it returns the id of the thread. What I really need is the id of the post when creating a new thread. Like I say, it's late and it might make more sense in the morning!
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jan 31, 2015 18:24:55 GMT -8
The thread_new hook automatically chooses the object_id during thread creation and that is determined by the key type being used in the call, so if your key is of type POST then the object_id chosen would be the id of the first post in the thread. On the other hand if the key type is type THREAD then the object_id chosen would be the id of the thread. Also the post_new hook only fires on a REPLY (not a create) if I am remembering correctly so it might make better sense if it was actually called reply_new instead to further solidify that distinction.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Feb 1, 2015 17:56:35 GMT -8
Cheers Chris for the help with this 'stuff'( as usual ). I assumed the thread_new was for thread keys and post_new being for posts. I've been told I assume a lot , and shouldn't. But who listens to that sort of advice! Anyway, back to my jumbled up code that even I can't follow anymore!
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Feb 2, 2015 21:14:17 GMT -8
post_edit and thread_edit hooks work. I use them in quarantine
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Feb 2, 2015 21:27:30 GMT -8
post_edit and thread_edit hooks work. I use them in quarantine But thread_edit works when editing first post and post_edit works when editing replies (i.e. all other posts except the first) or at least that is what my dog keeps barking at me since he wrote a plugin using those hooks. Is that correct?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Feb 2, 2015 22:10:14 GMT -8
you quoted me before i corrected it. thread_edit is for the first post in a thread. post_edit was for all the others.
|
|