View Full Version : Quick edit ajax question
Boofo
04-05-2011, 09:00 PM
I'm stuck here, guys. I have a replacement variable in my sig. When I do a quick edit of the post, after I save it, you can see the variable. When I refresh the page, the variable is parsed like it should be. Is there a hook that deals with the ajax portion of that so it can be parsed without having to refresh the page first?
Boofo
04-14-2011, 12:33 PM
No one has any ideas on this?
I'd like to know the answer to Boofo's question as well :-/
Can you have replacement variables in a sig? It sounds like a mod that doesn't completely work right.
I was actually wondering why this doesn't work on postbit_display_complete:
$ok_ids = $vbulletin->options['allowedforum_ids'];
$ok_ids_array = explode("," , $ok_ids);
if (in_array( $foruminfo['forumid'],$ok_ids_array))
{
$links = explode(',',$thread['links']);
$scans = explode(',',$thread['scans']);
array_pop($links);array_pop($scans);
vB_Template::preRegister('postbit_legacy',array(
'links' => $links,
'scans' => $scans
));
vB_Template::preRegister('postbit',array(
'links' => $links,
'scans' => $scans
));
}
It should display two boxes beneath the post text, which does fine but after using the quick edit it disappears and I have to refresh.
I was actually wondering why this doesn't work on postbit_display_complete:
Oh, ok. I think the reason is that $vbulletin and $foruminfo don't seem to be available at that hook. For $vbulletin you can put in a "global $vbulletin" or you can use $this->registry instead. And it looks like you can use $forum instead of $foruminfo.
You're right, but that didn't help either, still after quick saving, the box disappears.
Scanu
08-22-2012, 01:25 PM
Lol guess what i'm asking to myself the same question ahaha
However kevin it seems that the code is working well, the problem is just the when you edit via ajax, i have fields for links and scans just on newthread.php and editpost.php when you click edit post (ajax) as you don't have links fields when you click save it seems to update links with empty values
Hmm...well, when I save after doing an inline edit, it seems to make 2 calls - one is to ajax.php with do=editorswitch, which seems to allow it to convert the message text based on the editor mode. Then it calls editpost with do=updatepost, and it looks to me like that ends up calling construct_postbit, which should run the postbit_display_complete hook code. I guess I'll have to experiment more to see if code on that hook can actually change the postbit in that situation.
Scanu
08-22-2012, 01:44 PM
Yes it's a bit difficult, there is only one hook for ajax edit, i serached for other mods and i found this: https://vborg.vbsupport.ru/showthread.php?t=250948 but if you disable redirecting plugins and try to do a quick edit it deletes the link, so he had the same problem. Another mod was this: https://vborg.vbsupport.ru/showthread.php?t=269667. But the ajax thing is a pro feature so nothing to do with it.
Hmm...well, when I save after doing an inline edit, it seems to make 2 calls - one is to ajax.php with do=editorswitch, which seems to allow it to convert the message text based on the editor mode. Then it calls editpost with do=updatepost, and it looks to me like that ends up calling construct_postbit, which should run the postbit_display_complete hook code. I guess I'll have to experiment more to see if code on that hook can actually change the postbit in that situation.
Yes, that is correct, that's why I was baffled when it didn't work :-/
Yes, that is correct, that's why I was baffled when it didn't work :-/
If you take away your "if" statements and hardcode your $links and $scans, does it work then? (Assuming it's a test forum - you wouldn't want to do that on a live forum of course). I was going to set up that test but it's probably easier for you.
Yes it's a bit difficult, there is only one hook for ajax edit, i serached for other mods and i found this: https://vborg.vbsupport.ru/showthread.php?t=250948 but if you disable redirecting plugins and try to do a quick edit it deletes the link, so he had the same problem. Another mod was this: https://vborg.vbsupport.ru/showthread.php?t=269667. But the ajax thing is a pro feature so nothing to do with it.
I'm not sure I understand, but if you're working with form fields that exist only when you're creating the post, then yeah, you'd need to save them somewhere so you can have them if the post is being edited (or somehow arrange for them to be submitted when the edited post is submitted, like hidden fields?). Edit: it seems like you'd have the same problem when non-inline editing a post, unless you expect the user to re-enter the info.
Scanu
08-22-2012, 02:59 PM
Well i've added a field to the new thread page then i saved it, after this i can use threadinfo['myfield'] in postbit_display_complete, i added the field to editpost.php too, where you can update this field, until now everything is ok i create a new thread and i put a value to my field and i can see it in the showthread page, if i click edit post and go advanced i can edit this value and it works fine, the problem was adding this field to quickedit so i decided to leave it just on editpost.php but actually if i click edit post and then save it deletes my value, i hope i made myself clear and again, sorry for my english
Well, I guess I'd have to study the mod to understand it completely. But at hook postbit_display_complete, you should have the thread info in $thread. The difference of course is that that's called when it's displayed instead of when it's saved in the db.
Scanu
08-22-2012, 03:32 PM
Ok i will try to add global $vbulletin and $thread instead of $threadinfo
If you take away your "if" statements and hardcode your $links and $scans, does it work then? (Assuming it's a test forum - you wouldn't want to do that on a live forum of course). I was going to set up that test but it's probably easier for you.
Nah it works fine, when the code is in postbit_display_complete and the thread is loaded the boxes show up, they just disappear for some reason after saving quick edit. I looked at the code I think postbit_display_complete should be called somewhere around that part, just not sure why it's not working.
Well, something's got to be different during the edit. I'll play around and see if I can figure out anything.
It somehow must go through inlinemod.php as well I think
Oh well, I'm already stumped. I added a variable to the postbit_legacy template and used preRegister to set the value in a plugin on postbit_display_complete using values from $vbulletin and $forum, and it works even if I inline edit.
Scanu
08-22-2012, 04:13 PM
Yes because the problem isn't there (i think) the problem is when you create a new field and then quick editing a post
Yes because the problem isn't there (i think) the problem is when you create a new field and then quick editing a post
What do you mean by "create a new field"? I was replying to Ziki's earlier post where he posted his plugin code that he said doesn't work when quick editing.
What do you mean by "create a new field"? I was replying to Ziki's earlier post where he posted his plugin code that he said doesn't work when quick editing.
He meant to say that it might be a problem if the field in question was added to the thread table through a product, so it's not in the default installation, but that's not it.
I'll try to check it again, maybe something is interfering, though I don't see what possibly could.
He meant to say that it might be a problem if the field in question was added to the thread table through a product, so it's not in the default installation, but that's not it.
Right, ok. Yeah, you guys have 2 different circumstances, although I suppose the problem could be the same. I have seen things disappear when you quick edit, only to come back when you refresh. But I can't remember what it was.
Scanu
08-22-2012, 08:48 PM
The code is the same as ziki is continuing my mod, btw the problem is that when you click quick edit it updates the variables with empty values, so even if you refresh values are gone...
--------------- Added 1345672192 at 1345672192 ---------------
As soon as i can i will show you this on my site
--------------- Added 1345675217 at 1345675217 ---------------
Username: demo
Pwd: test
Go here (http://scanu.altervista.org/newthread.php?do=newthread&f=19), compile all fields then press "Submit New Thread" you will be redirected to the post where you can see two boxes so everything is fine try to edit your post and go advanced you can edit your values and then save, it will works. Now click edit post (whitout going to advanced) and then click save, you will see the problem (even when refreshing)
The code is the same as ziki is continuing my mod,
Oh...then I guess I just don't understand what's going on. :o
Scanu
08-22-2012, 10:18 PM
Basically i can solve this probem adding fields to the quick edit but i don't know how :/
Oh...then I guess I just don't understand what's going on. :o
The thread is getting derailed :D Can you post your test code that worked on your test board? Perhaps I'm missing something minor.
It's just this:
global $vbulletin;
vB_Template::preRegister('postbit_legacy', array('testvar' => $forum['forumid']));
and I inserted "Test var: {vb:raw testvar}" in my postbit_legacy. That's the latest code - I was changing it to test different things, so I previously had it displaying some $vbulletin options values just to make sure they were set as expected (I had been thinking maybe if it was an ajax call that not everything was being loaded like on normal request).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.