×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Hiding Comments

Hiding Comments 15 years 4 months ago #4932

  • James
  • James's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 8
  • Thank you received: 0
I can't believe no one has asked this yet (well, at least I cannot find it). Is it possible to have comments hide after a certain number of negative votes?

If not, tell me what part of which file to modify in order to add this, thanks.

Hiding Comments 15 years 4 months ago #4934

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey James,
No you are not able to make this right now.

Every comment that has a lot of negatives votes (2 times more negative than positive votes) get a class #hide. We just tell this class to look grey so that the comment is not so easy readable. If you know any javascript then you can hide the comment or perhaps we can add that to a template.

edit: there seems to be a bug in the forum software - that is why this post is on a first place, instead of second.

Hiding Comments 15 years 4 months ago #4936

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
I think this is not as good idea as it might first sound for one simple reason - in JoomlaComment, currently there's no "checking" for multiple votes. This means that a single user can continuously give negative votes to one comment - there is no way to check for multiple from the source IP I think and it would be pretty intense to implement....?

In regards to hiding via #class, I think we don't even need JavaScript to do it - it is do-able via PHP and CSS i'm sure, but to have the "This comment was hidden due to bad ratings. Click here to unhide" text will probably have to be AJAX yeah :)

I will remember this when working on the new template(s).

Hiding Comments 15 years 4 months ago #4945

  • James
  • James's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 8
  • Thank you received: 0
Yeah, a modified template sounds good. I copied a template and the took a look at it - but wasn't sure what I could do with it in this regards.

Hiding Comments 15 years 4 months ago #4949

  • James
  • James's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 8
  • Thank you received: 0
Ok, here is my kludge...

In a template, just before {post}, put this Javascript:
<script type="text/javascript">
    function HideBadComment(id) {
        var contentChild = document.getElementById("content"+id);
        var moreElement = document.getElementById("more" + id);
        var moreHTML = "<font color='#d0d0d0'><i>(more...)</i></font>";
        var lessHTML = "<font color='#404040'><i>(less)</i></font>";
        if (contentChild && moreElement) {
            if (contentChild.firstChild.className == "hide") {
                moreElement.innerHTML = moreHTML;
                moreElement.isHidden = true;
                moreElement.onclick = function() {
                    if (this.isHidden) {
                        this.isHidden = false;
                        this.innerHTML = lessHTML;
                        contentChild.firstChild.className = "";
                    } else {
                        this.isHidden = true;
                        this.innerHTML = moreHTML;
                        contentChild.firstChild.className = "hide";
                    }
                }
            }
        }
    }
</script>
and just BEFORE {/post}, put this line:
<script type="text/javascript">HideBadComment("{id}");</script>
Finally, look for this:
<td style='overflow: hidden;'>{content}</td>
... and replace with ...
<td id="content{id}" style='overflow: hidden;'>{content}<div id="more{id}" style="cursor:pointer; cursor:hand;" /></td>
Enjoy! B)

p.s. On a different topic, after taking time to contribute this, I hope you will be able to (soon) add code to store the logged-in user ID for each vote, in addition to the IP, and go by that instead (for security), thanks.

Hiding Comments 15 years 4 months ago #4956

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
James,

Thanks for that sweet action of Java script there! Since I don't deal with Java pretty much ever, is that sort of thing XHTML valid? Or does it have to be in a seperate .js file?

Anywho, I will definately save this thread for when we crack at the new templates in new releases :) the IP+username checking is a definate necessity. I've referrenced this thread in the dev site and submitted it as a future feature :) Thanks a lot James!

Hiding Comments 15 years 4 months ago #4957

  • James
  • James's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 8
  • Thank you received: 0
Cool, thanks. No, nothing else is required. Also, it was tested and works on FireFox, IE, and Chrome. The script is only attaches an event to posts that have the "hide" class.

p.s. I have a work-around for the user_id vs IP issue (see other thread).

[edit]
Oh, you mean can it be in another file? I'm sure it could, just need need to make sure the file can be found in relation to the page that parses the template.
  • Page:
  • 1
Time to create page: 0.117 seconds