bbPress Plugin Browser »

BBPress:Live Comment (0.1)

Download

Version: 0.1

Last Updated: 2009-7-20

Requires bbPress Version: 0.8.3.1 or higher

Compatible up to: 0.8.3.1

Author Homepage »

Plugin Homepage »

Donate to this plugin »

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(4)

Your Rating

Author: Enrique Chavez aka Tmeister

Provide users with a live comment preview before submit. show it in the same page using Ajax


  1. Good plugin!

    But in javascript file live_comment_preview.js I renamed the function Ajax() to lcp_Ajax() and changed the call in sendPostToPreview, to avoid conflicts with Ajax prototype functions in another plugins.

    Posted: 3 years ago #
  2. It didn't work for me even though I copied and pasted the code into my topic.php file exactly where you suggested =(

    Posted: 3 years ago #
  3. Tmeister, (or anyone) do you have thoughts on how to make this work for the first post in a thread? Putting the add_live_comment_preview tag in post-form.php causes the post to submit.

    ~ ~ ~ ~ ~ ~ ~

    Dees, in the file live_comment_preview.php, look for

    my-plugins

    and change it to

    bb-plugins

    Posted: 3 years ago #
  4. A few small suggestions:
    Line 14 live_comment_preview.php:
    $live_comment_preview_path = defined('BBPLUGINURL') ? BBPLUGINURL . 'live-comment-preview' : bb_get_option('uri') . 'bb-plugins/live-comment-preview';

    Line 23 (language attr is deprecated by W3C):
    $head .= "<script type='text/javascript' src='".$live_comment_preview_path."/live_comment_preview.js'></script>\n";

    Lines between 33&39 (We don't need interpret anything of HTML code brrr :(
    And, if you add the code to the differents forms, "return false" it's a good practice):
    echo '
    <div id="live_comment_preview_main_content"></div>

    <div id="live_comment_preview_button_div">
    <input type="submit" name="live_comment_preview_submit" id="live_comment_preview_submit" value="'.$label.'" onclick="sendPostToPreview(\''.$live_comment_preview_path.'\'); return false;" tabindex="5" />

    </div>';

    Regards

    PD: Tabindex for a web of quality ^^

    Posted: 3 years ago #
  5. So... we don't need HTML code extra:

    function add_live_comment_preview($label) {
    	global $live_comment_preview_path;
    	if( bb_is_user_logged_in() ) :
    		echo '
    		<input type="submit" name="live_comment_preview_submit"
    id="live_comment_preview_submit" value="'.$label.'"
    onclick="sendPostToPreview(\''.$live_comment_preview_path.'\');
    return false;" tabindex="5" />
    		<div id="live_comment_preview_main_content"></div>';
    	  endif;
    }

    This change allow you to put the preview button next to the submit button and can you apply style for both buttons.
    The div for preview is aside.

    Great plugin, regards.
    Srry lang.

    Posted: 3 years ago #
  6. citizenkeith

    Member

    Works, but this is appears before the preview:

    bbPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
    SELECT post_read FROM bb_utplugin_log WHERE user_id = 1 AND topic_id =
    
    bbPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' )' at line 1]
    INSERT INTO bb_utplugin_log (user_id, topic_id, post_read) VALUES ( 1, , )
    
    bbPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
    SELECT post_read FROM bb_utplugin_log WHERE user_id = 1 AND topic_id =
    
    bbPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' )' at line 1]
    INSERT INTO bb_utplugin_log (user_id, topic_id, post_read) VALUES ( 1, , )
    Posted: 3 years ago #
  7. pomeid

    Member

    Not working for me (bbpress 0.9.0.2). No effect in post.php and actually submit the replies in post-form.php. I've fixed the path from my-plugins to bb-plugins like intellivision said.

    Posted: 3 years ago #
  8. emmegildo

    Member

    work perfectly for me in bbpress 0.9!! thank you very much

    Posted: 3 years ago #
  9. SteveG190

    Member

    Anyone have any idea why this is stripping line spacing when I try to preview a post?

    Posted: 3 years ago #
  10. using 0.9.0.2

    Followed installation instructions. Activated it. Placed the code in topic.php

    Nothing happened :O

    Posted: 3 years ago #
  11. meitershaker

    Member

    hi, with the 1.0 alpha, the ajax effect doesn't work, i have only the button lol

    Posted: 3 years ago #
  12. I can't get this to work, nothing happens when I press the preview button.

    sendPostToPreview is not defined
    http://forums.mudlet.org/topic/previewing-posts/event/trdpw%2F4LSoYS%2B0BShZrk1g%3D%3D
    Line 2

    Posted: 3 years ago #
  13. I got it. The plugin folder name uses - instead of _'s as the plugin expects.

    Posted: 3 years ago #
  14. Well, it didn't come at a cost, the bbCode buttons now do not show.

    Posted: 3 years ago #
  15. Hey,
    Has anyone gotten this plugin to work with bbPress 1.0 alpha?

    Posted: 3 years ago #
  16. Anyone having the problem of the preview being stopped when an ampersand is hit?

    Typing the following: "This is a & Test!" will only preview as "This is a ".

    This is causing problems with the quote plugin since it uses ampersands in the code for quoting other users.

    Posted: 3 years ago #
  17. Thanks for that fix, Covi! :D

    Posted: 3 years ago #
  18. By the way, you could make the preview process automatic by setting a setTimeout or interval where every 30 seconds it checks the postform textarea for content and updates the preview.

    Posted: 3 years ago #
  19. Is this pluggin compatible with bbPress 1.0 Alpha?

    I attempted the pluggin with a dry(original files) installation and trial with no success, many modifications later my live_comment_preview.php now looks like this:

    <?php
    $live_comment_preview_path=defined('BBPLUGINURL')?BBPLUGINURL.'live_comment_preview':bb_get_option('uri'). 'bb-plugins/live_comment_preview';
    function live_comment_preview_header()
    {
    global $live_comment_preview_path;
    $head="<link rel='stylesheet'href='".$live_comment_preview_path."/style.css' type='text/css' media='all'/>\n";
    $head.="<script type='text/javascript'src='".$live_comment_preview_path."/live_comment_preview.js'></script>\n";
    echo $head;
    }
    function add_live_comment_preview($label){
    global $live_comment_preview_path;
    if(bb_is_user_logged_in()):
    echo '<input type="submit"name="live_comment_preview_submit"
    id="live_comment_preview_submit"value="'.$label.'"
    onclick="sendPostToPreview(\''.$live_comment_preview_path.'\');
    return false;"tabindex="5"/>
    <div id="live_comment_preview_main_content"></div>';
    endif;
    }
    add_action('bb_head', 'live_comment_preview_header');?>

    And I've added the line: <?php add_live_comment_preview("View Preview");?> as seen here in topic.php:

    <?php bb_get_header(); ?>

    <h3 class="bbcrumb">"><?php bb_option('name'); ?><?php bb_forum_bread_crumb(); ?></h3>
    <div class="infobox">

    <div id="topic-info">
    <span id="topic_labels"><?php bb_topic_labels(); ?></span>
    <h2<?php topic_class( 'topictitle' ); ?>><?php topic_title(); ?></h2>
    <span id="topic_posts">(<?php topic_posts_link(); ?>)</span>

    <ul class="topicmeta">

  20. <?php printf(__('Started %1$s ago by %2$s'), get_topic_start_time(), get_topic_author()) ?>
  21. <?php if ( 1 < get_topic_posts() ) : ?>

  22. <?php printf(__('Latest reply from %2$s'), attribute_escape( get_topic_last_post_link() ), get_topic_last_poster()) ?>
  23. <?php endif; ?>
    <?php if ( bb_is_user_logged_in() ) : $class = 0 === is_user_favorite( bb_get_current_user_info( 'id' ) ) ? ' class="is-not-favorite"' : ''; ?>
    <li<?php echo $class;?> id="favorite-toggle"><?php user_favorites_link(); ?>
    <?php endif; do_action('topicmeta'); ?>

    </div>

    <?php topic_tags(); ?>

    <div style="clear:both;"></div>
    </div>
    <?php do_action('under_title'); ?>
    <?php if ($posts) : ?>
    <div class="nav">
    <?php topic_pages(); ?>
    </div>
    <div id="ajax-response"></div>
    <ol id="thread" class="list:post">

    <?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
    <li id="post-<?php post_id(); ?>"<?php alt_class('post', $del_class); ?>>
    <?php bb_post_template(); ?>

    <?php endforeach; ?>

    <div class="clearit"><br style=" clear: both;" /></div>
    <p class="rss-link">" class="rss-link"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr> feed for this topic') ?></p>
    <div class="nav">
    <?php topic_pages(); ?>
    </div>
    <?php endif; ?>
    <?php if ( topic_is_open( $bb_post->topic_id ) ) : ?>
    <?php add_live_comment_preview("View Preview");?>
    <?php post_form(); ?>
    <?php else : ?>
    <h2><?php _e('Topic Closed') ?></h2>
    <p><?php _e('This topic has been closed to new replies.') ?></p>
    <?php endif; ?>
    <?php if ( bb_current_user_can( 'delete_topic', get_topic_id() ) || bb_current_user_can( 'close_topic', get_topic_id() ) || bb_current_user_can( 'stick_topic', get_topic_id() ) || bb_current_user_can( 'move_topic', get_topic_id() ) ) : ?>

    <div class="admin">
    <?php bb_topic_admin(); ?>
    </div>

    <?php endif; ?>
    <?php bb_get_footer(); ?>

    I get the "View Preview" button as meitershaker stated working, but when pressed, it is unresponsive.

    If you have the time, please comment on this compatibility issue.

Posted: 3 years ago #