• I have ported the live preview hack from MT to WP.
    Basically this hack allows your users to see a live preview of what they are writing below the comment entry box.
    Currently it uses onkeyup, but you could easily change it to onblur if you don’t want the realtime updating.
    This is pretty easy all things considered, and could pretty painlessly be implemented on the wp-admin/post.php page as a stop gap until the preview function is back.
    Here it is:
    Find it over on my blog, there was something screwy going on here, so I took down the code I had pasted here. You can find it at this link: https://chrisjdavis.org/index/2004/03/15/live-preview-for-comments/463/
    That is about it. I have this hack running on my site currently, so you can go on over there and see it in action. Just leave a comment!
    https://chrisjdavis.org

Viewing 15 replies - 1 through 15 (of 25 total)
  • Pretty cool. I never knew about the innerHTML method in javascript before…

    Before everyone jumps all over this, I just tried it at Jesuit’s site, and it didn’t seem to work. Running FF 0.8 here. As I was reading this, I was wondering about if innerHTML was an IE thing….looks like it is…
    TG

    Thread Starter Chris J. Davis

    (@chrisjdavis)

    No, its not. I wrote it using FF 0.8 as a test browser and I wrote a response to you (TechGnome) on my site using Safari and it worked just fine. Not sure what your issue is.
    And I responded again using FF 0.8 for Panther and it was fine as well. Don’t know what to tell you.
    Anyone else who would like to try this, go to this post:
    https://chrisjdavis.org/index/2004/03/15/live-preview-for-comments/463/
    and test it out, and then leave me a comment there or here to let me know if there is something screwy going on.
    Thanks.
    Jesuit

    Works great in Opera 7.22 — good work!

    oooh.. opera!!! i would have to try it now…
    does it validate?

    Thread Starter Chris J. Davis

    (@chrisjdavis)

    It does now, I had forgotten that XHTML didn’t have the language attribute. If you are already running this just delete the language=”javascript” and it will validate.
    And thanks everyone for checking it out and letting me know if it worked or not.
    Jesuit

    Honest! I swear! It wasn’t working, but now it is. The only thing I can think of was that I had the first comment…. ?????
    I sit corrected. Looks greast too!
    TG

    Thread Starter Chris J. Davis

    (@chrisjdavis)

    TechGnome: not a problem brother, I was starting to freak out before other people reported that they could use it!
    I just hope people can get some use out of it. I certainly love it.

    Hi Jesuit,
    I tried to use your plugin in WordPress 1.2, but could not make it work properly.
    I saved the file in the plugin directory, and activated it.
    But what should I change in wp-comments.php, in order to have the preview?
    Plus, the wp-preview.phps available in https://chrisjdavis.org/hacks/wp-preview.phps does not end in ?>. Is it ok anyway?
    Any help would be greatly appreciated.

    Are there any plans to update hack for WP 1.2?

    I found that this version .65 RC1 doesn’t work as a plugin for 1.2, but does work if you cut and paste the functions into your my-hacks file and call the functions as instructed.
    I look forward to this being developed as a plugin, but because it doesn’t rely on any hook or action I dunno how it will.

    Sorry seriocomic could you elaborate a bit on your post. I’m trying to get this to work but I think my serious lack of php skills at the moment might be the cause, does this hack work with 1.2 or not? Is my-hacks another plugin that you can put all the functions into and then call them from there?
    Also is it possible to elaborate on one thing specifically that has eluded me completely. I don’t understand where I should be putting the onkeyup function. The documentation says that it should be included in the two following files, but
    a) I’m not sure which ones
    b) more importantly I don’t know where and how.
    Any elaboration would be brilliant.

    It’s not working for me. What am I doing wrong? I activated the plugin. Then I made these 3 changes to the wp-comments.php file (with their following lines included for reference):
    1.

    <?php commentScript() ?>
    <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

    2.

    <h2 id="comments" onkeyup="ReloadTextDiv();" ><?php comments_number(__("Comments"), __("1 Comment"), __("% Comments")); ?>
    <?php if ('open' == $post->comment_status) { ?>

    3.

    <?php comments_Div() ?>
    <?php } else { // comments are closed ?>

    Great! I got it working. I changed number 2 to:

    <textarea name="comment" id="comment" onkeyup="ReloadTextDiv();" cols="35" rows="4" tabindex="4"></textarea>

    Thanks for the help.

    I am having huge problems with this. Everything seems to work (ie the previewing) until I try to submit a comment or even login to wp-login.php. Then I get a whole bunch of Warning: Cannot modify header information – headers already sent by (output started at …./liveupdate.php:43) in ……
    I really have no idea what is going but I have disabled the plugin by changing its name back to .phps and everything is back to normal.. Except I really like this plugin and want to use it.
    Any suggestions?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Comments: Live Preview’ is closed to new replies.