Home / Forums / DynamiX Support / Comments in accordion: almost there!

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts

  • Diego Meozzi
    Participant

    Hi,

    A couple of weeks ago I asked how to keep all comments inside an accordion, so to make those comments appear only when the accordion title is being clicked. Andy's solution was:

    You would have to manually add reveal code to the page.php file. This is the code for reveal: 


    <div class="revealbox blue clearfix" '. $width .'><h4 class="reveal"><span class="ui-icon"></span>TITLE</h4><div class="reveal-content"> COMMENT CODE </div></div>

    However, I have discovered that doing that definitely works, but let the "TITLE" appear anyway, even if there are no comments or (which is worse) even if the comments are turned off. So, I had to place that code inside the comments.php page instead, and doing it twice to allow the loop work as expected. See my modified code bits here:


    <?php if ( have_comments() ) : ?>
    <div class="revealbox blue clearfix" '. $width .'><h4 class="reveal"><span class="ui-icon"></span>Comments - <?php comments_number(__('Be the first to write one', 'DynamiX' ), __('Read 1 comment', 'DynamiX' ), __('Read % Comments', 'DynamiX' ) );?></h4><div class="reveal-content">
    <div class="comments-wrap">
    <!--
    <h3 id="comments"><?php comments_number(__('No Responses to', 'DynamiX' ), __('One Response to', 'DynamiX' ), __('% Responses to', 'DynamiX' ) );?> “<?php the_title(); ?>”</h3>
    -->
    <div class="navigation">
    <div class="alignleft"><?php previous_comments_link() ?></div>
    <div class="alignright"><?php next_comments_link() ?></div>
    </div>

    <ol class="commentlist">
    <?php wp_list_comments('type=comment&callback=dynamix_comment'); ?>
    </ol>

    <div class="navigation">
    <div class="alignleft"><?php previous_comments_link() ?></div>
    <div class="alignright"><?php next_comments_link() ?></div>
    </div>

    </div><!-- /comment-wrap -->

    <?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. -->
    <div class="revealbox blue clearfix" '. $width .'><h4 class="reveal"><span class="ui-icon"></span>Comments - <?php comments_number(__('Be the first to write one', 'DynamiX' ), __('Read 1 comment', 'DynamiX' ), __('Read % Comments', 'DynamiX' ) );?></h4><div class="reveal-content">
    <?php else : // comments are closed ?>
    <!-- If comments are closed. -->
    <?php endif; ?>

    Of course, I had to close the two new div tags before the last endif of that page.

    Now everything works beautifully, but 1 thing: When anybody either adds a new comment or replies to an existing one, the page reloads and the accordion closes itself, making its contents temporarily not visible to the vistitor that tries to add a reply or would like to see his new comment posted. 

    My question is: is there anything I can do to force the accordion open after a reply or a new comment?


    Diego Meozzi
    Participant

    Hope to find a solution to this issue soon… Any help would be greatly appreciated!

    Andy
    Andy
    Keymaster

    Hi Diego,

    This is out of the realms of my support now – you ideally need to hire a developer, the support I offer can only be for standard theme issues and not customisations. Sorry. 

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.