Skip to:
Content
Pages
Categories
Search
Top
Bottom

Collapse and expand comments

  • @jasonbrodbeckcom

    Member

    IF the comments reach past 5 comments the page gets preatty full if there a way to collapse and expand like facebook?

Viewing 19 replies - 1 through 19 (of 19 total)
  • @djpaul

    Keymaster

    Do you mean in the activity stream?

    @naijaping

    Participant

    @jasonbrodbeckcom

    Member

    @djpaul Yes i do

    @jasonbrodbeckcom

    Member

    @naijaping I dont belive it does that

    @jasonbrodbeckcom

    Member

    @naijaping I dont belive it does that

    @yadigit

    Participant

    I just learned how to do that. in the Global.js located (/plugins/buddypress/bp-themes/bp-default/_inc) you will see Global,js.. open it up with a text editor ( I use notepad++ ) go to line 1200 and you will see
    `if ( jq(this).children(‘ul’).children(‘li’).length < 5 ) return;` Replace the 5 with what ever number you want it to hide when it reaches that limit.

    Now on line 1212 you will see
    `if ( i < comment_lis.length – 5 ) {`
    Once again change the 5 with what ever number you want it to hide when it reaches that limit,
    Let me know if it works @mary Jane

    @yadigit

    Participant

    Now the question is, is there a way to show the comments by clicking “Comment” and it will expland the rest of the hidden comments?

    I know it has something to do with the J.S
    @naijaping Any ideas?

    @jasonbrodbeckcom

    Member

    Your just …..your the best thanks so much, any way to collapse it as is “Hide comments” after you open them?

    @jasonbrodbeckcom

    Member

    @yadigit

    Participant

    I do have a script for that. But the javascript does effect the BP notifications… that’s the only problem. I’ll be more then happy to send you the script. @jasonbrodbeckcom, I don’t use it for that reason but let me see if I can find it again.

    @yadigit

    Participant

    I believe I have the comment script some where. I believe my buddy of mine has it.. He wont be on till later tonight. if he still has it i’ll be more then happy to send it over.
    @jasonbrodbeckcom

    @yadigit

    Participant

    Yey, I found it =D this requires editing the activity/entry.php in your theme.

    right after the following code:
    `

    `
    Put in:
    `

    $(document).ready(function(){

    $(“li#activity- div.activity-comments ul”).hide();

    $(“li#activity- a.acomment-reply”).click(function(){
    if ( $(“p.collapse-“).css(“display”) == ‘none’ ){

    $(“p.expand-, p.collapse-, li#activity- div.activity-comments ul”).toggle(100);

    }
    return true;
    });

    $(“p.expand- a”).click(function(){

    $(“p.expand-, p.collapse-, li#activity- div.activity-comments ul”).toggle(100);
    return false;

    });

    $(“p.collapse- a”).click(function(){

    $(“p.expand-, p.collapse-, li#activity- div.activity-comments ul”).toggle(100);
    return false;

    });

    $(“li#activity- input[name=ac_form_submit]”).click(function(){

    if ( $(“p.collapse-“).css(“display”) == ‘none’ ){

    $(“p.expand-, p.collapse-, li#activity- div.activity-comments ul”).toggle(100);

    }
    return true;
    });

    });

    `
    Please NOTE:
    the “
    should go above
    `

    `
    and the “
    goes under it.

    Any question’s please contact me at
    http://www.yadigit.net..
    Username MrMike.
    It should work just find for you. =D
    Your welcome.

    @yadigit

    Participant

    @amalsh

    Participant

    Hi @yadigit,

    Thanks for the solution! I have a question maybe you can help me with:
    When “loading more” activity stream, hiding comments doesn’t work i.e. all comments for activity updates appear which is not lovely!
    Why is that happening? How to fix this?

    Thank a lot
    Hope

    @amalsh

    Participant

    Anybody’s help will be much appreciated.. Thanks

    @yadigit

    Participant

    @amalsh I’ve never really had a problem with it. Yet again the code listed above was ment for an older version on bp and WP.. It sounds like a conflicting Java or Ajax that could cause the problem. Now the question is, does it do it to every single one or just the ones loaded afew clicking load more.. If its just happening to the ones that is loaded after clicking load more I would follow the code from where the button is and find out how the code is getting loaded.. If I recall it just loops the entry.php file.. I haven’t played with bp for a while but I’ll love to help. Best thing to do is to follow the load more code and find out what its doing.. I’m pretty sure it deals with Java or Ajax.. Probably Ajax (I don’t have the files to look at them).. If the button is powered by Ajax try turning it into a regular html like but don’t have it reload the page..

    after saying all that I just remembered that you don’t have to use the code at all.. I believe it has it built into it already… Inside golbal.js there is a code tords the button where it will hide the comments if they exceed more then 5.. Your best bet is to find that code and change the 5 to a 2 or even a 0 if you like.. I’d search for it inside .js files before editing the .php files and doing what I said before. If you have any problems with it just let me know and I’ll pull up old files and locate it for you

    @amalsh

    Participant

    Hi @yadigit

    Thanks a lot for your quick reply.. Actually I’m aware of the code in global.js file & I changed the number of shown comments to 2 instead of the default (5) but this is not my problem.

    I’ll describe the problem in more details:
    After changing the number to 2 in global.js file, comments appear on the activity stream just as I want (2 shown comments & the rest are hidden) but when I click on “Load More” buttom, the comments of the newly loaded activity updates are shown totally (no hidden comments).

    So what could the problem be? 🙁

    @amalsh

    Participant

    This is the “load more” code in global.js that deals with the comments’ hiding:
    `/* Hide excess comments */
    if ( jq(‘div.activity-comments’).length )
    bp_dtheme_hide_comments();`

    The required code is already in the called function bp_dtheme_hide_comments(); It should work :S Is there something I’m not seeing 😐

    @yadigit

    Participant

    Ok. Do some research on conflicting Java scripts. You may have to take the same code and rewrite it a different way so the codes don’t conflict.. I’m not sure how well you understand java. Also. Go into the config.php in the WordPress and turn on the debugging mode and click the load more button.. You might be able to get an idea of what’s going on if the debugging gives it to you.. Also what’s the site address?
    @amalsh

Viewing 19 replies - 1 through 19 (of 19 total)
  • The topic ‘Collapse and expand comments’ is closed to new replies.
Skip to toolbar