• Resolved havenwebmanagement

    (@havenwebmanagement)


    This really needs to be a feature in the plugin. The wall gets taken up by too many comments. The problem with the following code that was posted is the button always shows if there is no comment made. Needs to only show when a comment is made. The other issue is this breaks replies to the comments Ajax load like it normally does. You have to refresh the page to see any nested comments or replies to replies. Is there any way to add this as a feature or fix the code that was posted?

    <?php
    add_action( 'wp_footer', 'add_comment_hide_show' );
    function add_comment_hide_show() {
        ?>
        <style>
            .activity-comments ul li[id^="acomment-"]{display: none;}
        </style>
        <script type="text/javascript">
            jQuery(function($) {
                setInterval(function() {
                    $('.activity-meta').each(function() {
                        if( !$(this).find('.show-comments').length ){
                            var html = '<a href="#" class="button bp-primary-action show-comments">Show/Hide Comments</a>';
                            $(this).find('.button.acomment-reply').after(html);
                        }
                    });
                }, 500);
                $('body').on('click', '.show-comments', function(e) {
                    e.preventDefault();
                    var obj = $(this).closest('.activity-content').next('.activity-comments').find('ul li[id^="acomment-"]');
                    obj.slideToggle();
                    return false;
                });
            });
        </script>
        <?php
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Youzify

    (@kainelabsteam)

    Hello @havenwebmanagement

    Thank you for reaching us

    At the moment, indeed hide/show button only can be achieved with that snippet. However, we will consider to make this as a feature in the future updates. ??

    Best Regards, KaineLabs Team.

    @havenwebmanagement

    How did you go with this, found a solution?

    If not, try the following version. NB I don’t even pretend to know what I’m doing so it’s definitely not the most elegant solution, just trial and error – hopefully someone that does know what they are doing will see this and tidy it up! That said, it works for me, with a couple of caveats (not related to this snippet).

    function add_show_hide() {
    ?>
    <style>
    .single-group .activity-comments ul{display: none;}
    </style>
    <script type="text/javascript">
    jQuery(function($) {
    	setInterval(function() {
    		$('.youzify-activity-statistics').each(function() {
    			if( !$(this).find('.show-comments').length ){
    				var html = '<a href="#" class="bp-primary-action show-comments" style="float: right; margin-left: 3px; margin-top: 23.75px; color: #f30707; font-size: 13px; font-weight: 900;">- show/hide</a>';
    				$(this).find('.youzify-post-comments-count').before(html); 
    			}
    		});
    		
    	}, 500);
    	
    	$('body').on('click', '.show-comments', function(e) {
    		e.preventDefault();
    		var obj = $(this).closest('.activity-content').next('.activity-comments').find('ul');
    		obj.slideToggle();
    		return false;
    	});
    	
    });
    </script>
    <?php
    }
    add_action( 'wp_footer', 'add_show_hide' );

    Your concerns:

    The problem with the following code that was posted is the button always shows if there is no comment made.

    Not with the above (see screencast demo below). Also note I moved where it shows up (seemed somewhat disconnected to me in the default position, slightly worried it may go unnoticed now so changed the colour).

    Needs to only show when a comment is made.

    Does with this snippet.

    The other issue is this breaks replies to the comments Ajax loads like it normally does. You have to refresh the page to see any nested comments or replies to replies.

    Replies show up as soon as Ajax does its thing (again, see screencast).

    Caveats:

    1. The actual comment count doesn’t increase until a page refresh. Personally, I see that as a bug and have just posted as such.
    2. Personally I’d prefer the comments to be collapsed as default. Still looking into that so if anyone has any ideas please share ??

    • This reply was modified 1 year, 9 months ago by Diabolo.
    • This reply was modified 1 year, 9 months ago by Diabolo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide show comments button’ is closed to new replies.