Helpful Information
 
 
Category: vBulletin.org Forum
Editpost preview

This is what the hack does: It let's you preview a message when you're editing it, you can only preview when you're posting or replying the way it is now:

It works on my testserver, but I've not tested on a 'live' forum, but it seems to be working allright...

Instructions

1 Backup your editpost.php file!!! and open the original one...

Then:

after:

if (!isset($action) or $action=="") {
$action="editpost";
}

insert:

if($preview AND $action="updatepost")
$action = "editpost";

after:

if ($action=="editpost") {

// draw nav bar
$navbar=makenavbar($threadinfo[threadid],"thread",1);

insert:

if($preview)
{ $parseurl=iif($parseurl=="yes",1,0);
$email=iif($email=="yes",1,0);
$allowsmilie=iif($disablesmilies=="yes",0,1);
$signature=iif($signature=="yes",1,0);

$previewmessage=$message;

if ($parseurl) {
$previewmessage = $postinfo[message]=parseurl($previewmessage);
}

$previewpost=1;
$previewmessage=bbcodeparse($previewmessage,$foruminfo[forumid],$allowsmilie);
$postinfo[message]=$message;

if ($signature) {
$previewmessage.=bbcodeparse("\n__________________\n$bbuserinfo[signature]",0,$allowsmilies);
}

eval("\$postpreview=\"".gettemplate("editpost_postpreview")."\";");

$parseurlchecked=iif($parseurl,"checked","");
$postinfo[allowsmilie] = $allowsmilie;
$postinfo[showsignature] = $signature;
$postinfo[iconid] = $iconid;
$postinfo[title] = $title;
$previewchecked=0;
}
else{
$postinfo[message]=htmlspecialchars($postinfo[pagetext]);
$parseurlchecked="CHECKED";
}

Replace:

$postinfo[message]=htmlspecialchars($postinfo[pagetext]);

with:

//$postinfo[message]=htmlspecialchars($postinfo[pagetext]);

replace:

if ($checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid='$userinfo[userid]' AND threadid=$threadinfo[threadid]")) {
$emailchecked="CHECKED";
} else {
$emailchecked="";
}

with:

if(!$preview)
$email=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$userinfo[userid] AND threadid=$threadinfo[threadid]");
$emailchecked=iif($email,"CHECKED","");

Make a new template called 'editpost_postpreview' with the following content:

<table width=100% border=0 cellspacing=1 cellpadding=4>
<TR bgcolor="#6c6081">
<TD valign=middle><smallfont color="#afa3c5"><B>Post Preview:</B></smallfont></TD>
</TR>

<tr bgcolor="#DEDEDE">
<td><normalfont>$previewmessage</normalfont></td>
</tr>
</table>

<br>

then edit your 'editpost' template:

insert the '$postpreview' variable at the appropiate place (look into the 'newthread' template for an example)

and replace:

<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">

with:

<INPUT TYPE="Submit" NAME="preview" ACCESSKEY="P" VALUE="Preview">
<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">

All done! Enjoy :)

I'll be working on the pm-preview btw

No-one's interested?

Sure i will use them both, I just wasn't doing much with hacks yet until 2.0 is released. I didn't want a beta 3 to come out and have to re-hack a bunch of stuff.

It would be great if you wrote a upgrade script that you ran and it automatically fixed the things, that way you could just update the script for each beta released.

Hi there,

hopefully didn't overlook something in between,
but I definetely would appreciate to use that hack!

Does it work for 2.0.1?
Did you have a solution meantime for PM Preview - I know there's a hack, just interested if you worked on it, too.

Thanks,
-Tom

Yes Mas*Mind, I am very interrested in that hack !

I run v 2.2.1 is your hack fixed for that version ?

any update since your former post ?

waiting for news, see you

great hack Mas*Mind

Thanks Mas*Mind! I really missed having the ability to preview my edited posts, especially when I'm using vB code. I keep finding myself using HTML instead and then I have to go in again and edit. This is a really good idea!

Does this work on 2.2.2?

Sweet Work!

I have installed it, but ist doesn´t work correct. :(
I can have a first preview and it works, but if I try to preview again, it posts the message. Any ideas?

Three comments about this hack:

1. You do not need a separate template (editpost_postpreview). The contents of the existing template, newpost_postpreview, are almost exactly the same, but are a bit more polished in terms of HTML coding (including being the standard vBulletin table-within-a-table which I guess gives you the border or whatever). Plus, using the existing template saves space (even if only a tiny amount) in the database. (I tested that doing this works, and can confirm that it does indeed work properly to use the existing template. All you have to do is first of all, not create the new template, or delete it if you already did, then in editpost.php, change the part you added that says "editpost_postpreview" so that it says "newpost_postpreview".)

2. Whenever making a vBulletin .php file use a template it didn't use before, you should add it to the "$templateused" section at the top of the file. I'm told this saves a database query. You should do this regardless of what you do about my #1 above.

3. When you click the button to edit a post, then you click the Preview button, the edit is submitted and saved to the database. This means that whatever changes you made are saved before you tell it to save them! This is not the desired behavior of the Preview function. If you want to "preview" something, that means you want to see what it looks like, before you commit to it, right? Well, the mere act of previewing something now means you've committed the changes! This is not good.

sorry guys, this was a beta for 2.01 if I'm correct. I've never tested it fully and never really released it fully (don't know why it says v2.2.2 before the title)

currently there's no change for me to work on this, so if a fellow hacker wants to do it: great :)

I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

@JJR512
We had the same thoughts, I also have just used the newpost_postpreview Template.

I have attached the fixed version.

Originally posted by Mystics
I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!This works great. Thanks, Mystics! :up:

Yep, works fine now! :)

Works great on 2.2.2.

Thanks.

Originally posted by Mystics
I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

@JJR512
We had the same thoughts, I also have just used the newpost_postpreview Template.

I have attached the fixed version.
Thanks a lot, Mystics !! Great upgrade.
I installed perfectly without any problem.

Just a couple of little things:
1) When an admin (me, for instance...) is previewing after edit an other user's post, the signature showed in preview mode is mine, instead of the user's one. When saved, everything works fine, as usual.
2) Html style question: how can I make the 'save changes' button selected by default as it was before adding a button just before ? I tried with 'tabindex' but ... :(

Thanks a lot.
Bye

Originally posted by Mystics
I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

@JJR512
We had the same thoughts, I also have just used the newpost_postpreview Template.

I have attached the fixed version. I just tried to install this hack on 2.2.5 but, I cant find the code<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">in the editpost template... Has it been changed to somthing else?

I found this:<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">I dont know if thats it or not, so yeah...

Thanks :)

Alan (DWZ)

Originally posted by DWZ
I found this:<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">I dont know if thats it or not, so yeah... Yes, that's the right code.

I'm using Mystics version on my forum and it stopped working after upgrading to v2.2.6. It seems to execute template 'standardredirect' in some way beacuse it's redirect to the post again after 1sec.

Please, can someone verify if this is working with v2.2.6.

Originally posted by webForum
Please, can someone verify if this is working with v2.2.6. It's working perfect with 2.2.6 :)

I think, you have forgotten this step:
Search for
-----------------------------------------------------------
if ($HTTP_POST_VARS['action']=="updatepost") {
-----------------------------------------------------------

REPLACE it with
-----------------------------------------------------------
if ($action=="updatepost") {
-----------------------------------------------------------Mystics

Yes, you're correct. I actually leaved it out since I thought both more or less did the same thing.

Many thanks Mystics :)

So really,<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">
Should be replaced with<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">
<INPUT TYPE="Submit" class="bginput" NAME="preview" ACCESSKEY="P" VALUE="Preview">Otherwise the Preview button will not be the same size. :cool:

Probably wouldn't hurt to change the tabindex= numbers for Preview, Save Changes & Reset Message.

For anyone still using this hack, I have fixed the problem with the signature showing for the original poster instead of the person editing the post.

Change:

if ($signature && $bbuserinfo[signature]) {
$previewmessage.=bbcodeparse("\n__________________\n$bbuserinfo[signature]",0,$allowsmilies);
}

To:

if ($signature) {
$userinfo=$DB_site->query_first("
SELECT signature
FROM user
WHERE userid='$postinfo[userid]'");
$post[username]=$postinfo[username];
$post['signature'] = bbcodeparse($userinfo['signature'],0,$allowsmilie);
eval("\$post[signature] = \"".gettemplate("postbit_signature")."\";");
$previewmessage.=$post['signature'];
}

It does add one query, but this is the only way to fix it AFAIK. ;)

works great on vbulletin 2.3 its a wonder why it isnt there as standard

very useful hack
thanks for it :)

Flawless via 2.3.0

/me clicks install

Very cool, i installed it, the only problem what i have is that the preview of the changes of the post looks good, but in the form the changes aren't there anymore. So i need to edit it again whenever i preview the edit post.

Anyone knows what could have caused that? Very ackward! :ermm:

Ps: I am still running my faitfulll vb 2.2.7

It's working perfect with 2.2.6 :)

I think, you have forgotten this step:
Search for
-----------------------------------------------------------
if ($HTTP_POST_VARS['action']=="updatepost") {
-----------------------------------------------------------

REPLACE it with
-----------------------------------------------------------
if ($action=="updatepost") {
-----------------------------------------------------------Mystics

Installed nicely into 2.3.5 Thanks.

Just posting here to point out that that part of code isnt actually in the first post instructions :( So I missed it twice until I came further into the thread. just an FYI










privacy (GDPR)