WordPress.org

Ready to get started?Download WordPress

Forums

Collapse-O-Matic
[resolved] Collapse comment form (9 posts)

  1. Holmbygden
    Member
    Posted 1 year ago #

    I want to collapse my comment form (not the comments). I don't know much at all about php. (My hompage is http://www.holmbygden.se )
    This is how my comments.php in TwentyEleven ends:
    ...
    <?php endif; ?>

    <?php comment_form(); ?>

    </div><!-- #comments -->

    I have tried something like this without success:
    [expand title="Open" swaptitle="Close"]
    <?php comment_form(); ?>
    [/expand]

    Is there any way to do something like this??
    Or am I totally on the wrong way?

  2. Baden
    Member
    Plugin Author

    Posted 1 year ago #

    I would recommend you use the roll-your-own method when working in a theme. Try something like this:

    <span class="collapseomatic" id="form<?php the_ID(); ?>">Open</span>
    <span id="swap-form<?php the_ID(); ?>" class="collapseomatic" style="display: none;">Close</span>
    <div id="target-form<?php the_ID(); ?>" class="collapseomatic_content">
    <?php comment_form(); ?>
    </div>

    Demo: http://spacedonkey.de/sample-page/

  3. Holmbygden
    Member
    Posted 1 year ago #

    Thanks!

    I finally got it expanding. But something else went wrong.
    Your, Badens, code put my sidebar with all the widgets below all the content... =(

    Got any solution to that?

  4. Baden
    Member
    Plugin Author

    Posted 1 year ago #

    sounds like there extra div tag someplace.
    1. it seems you are using the twentyeleven template, which file did you modify?
    2. where exactly is this happening: everyplace? single posts/pages? a list of articles? link please.

  5. Holmbygden
    Member
    Posted 1 year ago #

    I tried to ad an extra "</div>" at the end, then the sidebar came back in place! EXPANDING COMMENT FORM and SIDEBAR PROBLEM SOLVED! =)
    1. Yes I am using twentyeleven. I edited the comment.php in /wp-content/themes/twentyeleven/.
    2. It happened everywhere. Sinple post, articlelist and pages.

    Now I've got some new problems... =/

    1. I don't want the Open/Close to appear where the comments aren't activated. Example not on this page: http://www.holmbygden.se/vader/
    Is it possible to insert some kind of IF ahead ocf the comment form code (maybe copy some from above about the commentlist?)?

    2. Now the comment form is in the bottom of all comments, example: http://www.holmbygden.se/gastbok/. I would like to place the comment formula above the comment list, under the Facebook-comments. Can I cut som code in the bottom of comment.php and paste above somewehere?

    3. There is much space between the facebook-comment form and the comment form in the article flow on the start page, http://www.holmbygden.se. Not a problem in the pages (http://www.holmbygden.se/gastbok/) or single posts (http://www.holmbygden.se/2012/05/31/se-filmen-den-magiska-kallan/). Where/how can I edit this space to make it smaller?

    Thanks very much so far!

  6. Holmbygden
    Member
    Posted 1 year ago #

    Right now this is my comment.php in the /wp-content/themes/twentyeleven/.

    <?php
    /**
     * The template for displaying Comments.
     *
     * The area of the page that contains both current comments
     * and the comment form. The actual display of comments is
     * handled by a callback to twentyeleven_comment() which is
     * located in the functions.php file.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    ?>
    	<div id="comments">
    	<?php if ( post_password_required() ) : ?>
    		<p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view 
    
    any comments.', 'twentyeleven' ); ?></p>
    	</div><!-- #comments -->
    	<?php
    			/* Stop the rest of comments.php from being processed,
    			 * but don't kill the script entirely -- we still have
    			 * to fully load the template.
    			 */
    			return;
    		endif;
    	?>
    
    	<?php // You can start editing here -- including this comment! ?>
    
    	<?php if ( have_comments() ) : ?>
    		<h2 id="comments-title">
    			<?php
    				printf( _n( 'Kommenterat om “%2$s”', '%1$s kommentarer om 
    
    “%2$s”', get_comments_number(), 'twentyeleven' ),
    					number_format_i18n( get_comments_number() ), '<span>' . 
    
    get_the_title() . '</span>' );
    			?>
    		</h2>
    
    		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there 
    
    comments to navigate through ?>
    		<nav id="comment-nav-above">
    			<h1 class="assistive-text"><?php _e( 'Comment navigation', 'twentyeleven' ); ?></h1>
    			<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 
    
    'twentyeleven' ) ); ?></div>
    			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 
    
    'twentyeleven' ) ); ?></div>
    		</nav>
    		<?php endif; // check for comment navigation ?>
    
    		<ol class="commentlist">
    			<?php
    				/* Loop through and list the comments. Tell wp_list_comments()
    				 * to use twentyeleven_comment() to format the comments.
    				 * If you want to overload this in a child theme then you can
    				 * define twentyeleven_comment() and that will be used instead.
    				 * See twentyeleven_comment() in twentyeleven/functions.php for more.
    				 */
    				wp_list_comments( array( 'callback' => 'twentyeleven_comment' ) );
    			?>
    		</ol>
    
    		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there 
    
    comments to navigate through ?>
    		<nav id="comment-nav-below">
    			<h1 class="assistive-text"><?php _e( 'Comment navigation', 'twentyeleven' ); ?></h1>
    			<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 
    
    'twentyeleven' ) ); ?></div>
    			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 
    
    'twentyeleven' ) ); ?></div>
    		</nav>
    		<?php endif; // check for comment navigation ?>
    
    	<?php
    		/* If there are no comments and comments are closed, let's leave a little note, shall we?
    		 * But we don't want the note on pages or post types that do not support comments.
    		 */
    		elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' 
    
    ) ) :
    	?>
    		<p class="nocomments"><?php _e( 'Comments are closed.', 'twentyeleven' ); ?></p>
    	<?php endif; ?>
    
    <span class="collapseomatic" id="form<?php the_ID(); ?>">Open</span>
    <span id="swap-form<?php the_ID(); ?>" class="collapseomatic" style="display: none;">Close</span>
    <div id="target-form<?php the_ID(); ?>" class="collapseomatic_content">
    <?php comment_form(); ?>
    </div>
    </div>
  7. Holmbygden
    Member
    Posted 1 year ago #

    [Resolved 2.]

    Cut out:

    <span class="collapseomatic" id="form<?php the_ID(); ?>">Open</span>
    <span id="swap-form<?php the_ID(); ?>" class="collapseomatic" style="display: none;">Close</span>
    <div id="target-form<?php the_ID(); ?>" class="collapseomatic_content">
    <?php comment_form(); ?>
    </div>

    Paste under:
    <?php // You can start editing here -- including this comment! ?>

  8. Holmbygden
    Member
    Posted 1 year ago #

    3.
    Noticed that the space gap between the facebook-comment form and the wordpress comment form is only when there are no facebook-comments written yet (both posts and pages).

    However I still don't know how to get rid och the space gap ("3."), but more important is that I don't know how to hide the collapse text when comments aren't allowed ("1.").

    EXAMPLE
    Comments are allowed:
    Works fine here: http://www.holmbygden.se/gastbok/
    Comments aren't allowed:
    Shouldn't be shown here: http://www.holmbygden.se/foreningar/

  9. Baden
    Member
    Plugin Author

    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic