Forums

Scrolling Comment in Box ? See examples (6 posts)

  1. tkaustin
    Member
    Posted 3 years ago #

    Hi,
    I appreciate in advance the help. Can someone out there tell me if they know of a plugin that will allow your comment section to show all the comments in a self-contained box, which you can scroll down?

    see an example below the posts here:

    http://www.njoythemoment.com.au/

    I've looked for days and haven't been able to find anything.
    Thanks

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    the author is basicall wrapping the comments into a div with fixed height and 'overflow-y:auto;' - here is the essential part of the css style:

    .comments-body {
    	height:137px;
    	border-left:none;
    	overflow:auto;
    	padding:5px 8px 8px 8px;
    }

    and this for instance could be the php code in comments.php to show the comments:

    <?php if ( $comments ) : ?>
    <div class="comments-body">
    <?php foreach ($comments as $comment) : ?>
    <p class="commentline"><span><?php comment_author_link() ?></span> - <?php comment_date() ?><?php edit_comment_link(__("Edit This"), ' '); ?></p>
    <?php comment_text();
    endforeach; ?>
    </div>
    <?php endif; ?>
  3. tkaustin
    Member
    Posted 3 years ago #

    thank you, ill take a look now- THANKS

  4. tkaustin
    Member
    Posted 3 years ago #

    Well, I may be missing something but in wordpress, I am not seeing any comments-body in the comments.php file.

    Unfortunately, I do not know PHP and am just a tad concerned I could mess it up by trying to edit. Do you know of a plugin that does the same thing or by any chance is there a coder out there that knows what I should do? again, humbly, thank you.

    (cut and pasted below)

    <?php
    // Do not delete these lines
    if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('Please do not load this page directly. Thanks!');

    if ( post_password_required() ) { ?>
    <p class="nocomments">This post is password protected. Enter the password to view comments.</p>
    <?php
    return;
    }
    ?>

    <!-- You can start editing here. -->

    <?php if ( have_comments() ) : ?>
    <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>

    <ol class="commentlist">
    <?php wp_list_comments(); ?>

    <div class="breaker"></div>
    <?php else : // this is displayed if there are no comments so far ?>

    <?php if ( comments_open() ) : ?>
    <!-- If comments are open, but there are no comments. -->

    <?php else : // comments are closed ?>
    <!-- If comments are closed. -->
    <p class="nocomments">Comments are closed.</p>

    <?php endif; ?>
    <?php endif; ?>

    <?php if ( comments_open() ) : ?>

    <div id="respond">

    <h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>

    <div class="cancel-comment-reply">
    <small><?php cancel_comment_reply_link(); ?></small>
    </div>

    <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    <p>You must be ">logged in to post a comment.</p>
    <?php else : ?>

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

    <?php if ( is_user_logged_in() ) : ?>

    <p>Logged in as /wp-admin/profile.php"><?php echo $user_identity; ?>. " title="Log out of this account">Log out »</p>

    <?php else : ?>

    <p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
    <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>

    <p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
    <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>

    <p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
    <label for="url"><small>Website</small></label></p>

    <?php endif; ?>

    <!--<p><small>XHTML: You can use these tags: <?php echo allowed_tags(); ?></small></p>-->

    <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>

    <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    <?php comment_id_fields(); ?>
    </p>
    <?php do_action('comment_form', $post->ID); ?>

    </form>

    <?php endif; // If registration required and not logged in ?>
    </div>

    <?php endif; // if you delete this the sky will fall on your head ?>

  5. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    make a backup copy of your files first, incase something goes wrong, so you can restore the status you have now.

    try and change this part of your code:

    <!-- You can start editing here. -->
    
    <?php if ( have_comments() ) : ?>
    <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
    
    <ol class="commentlist">
    <?php wp_list_comments(); ?>
    
    <div class="breaker"></div>
    <?php else : // this is displayed if there are no comments so far ?>
    
    <?php if ( comments_open() ) : ?>
    <!-- If comments are open, but there are no comments. -->
    
    <?php else : // comments are closed ?>
    <!-- If comments are closed. -->
    <p class="nocomments">Comments are closed.</p>
    
    <?php endif; ?>
    <?php endif; ?>

    into this:

    <!-- You can start editing here. -->
    
    <?php if ( have_comments() ) : ?>
    <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
    
    <div class="comments-body"> <!--start of the comments scroll box-->
    <?php foreach ($comments as $comment) : ?>
    <p class="commentline"><span><?php comment_author_link() ?></span> - <?php comment_date() ?><?php edit_comment_link(__("Edit This"), ' '); ?></p>
    <?php comment_text();
    endforeach; ?>
    </div><!--end of the comments scroll box-->
    
    <div class="breaker"></div>
    <?php else : // this is displayed if there are no comments so far ?>
    
    <?php if ( comments_open() ) : ?>
    <!-- If comments are open, but there are no comments. -->
    
    <?php else : // comments are closed ?>
    <!-- If comments are closed. -->
    <p class="nocomments">Comments are closed.</p>
    
    <?php endif; ?>
    <?php endif; ?>

    hope this works - it's not tested, but i have similar code running in my blog.
    good luck ;-)

  6. Rtune
    Member
    Posted 3 years ago #

    This is very helpful. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.