Hi everyone,
I'm using P2 theme. Is there a way to hide threads on homepage by default?
Hi everyone,
I'm using P2 theme. Is there a way to hide threads on homepage by default?
I'm also interested in knowing how to do this.
I see no default way to do this...for a quick fix just:
In file 'index.php' change:
<?php _e('Hide threads', 'p2'); ?>
to
<?php _e('Show threads', 'p2'); ?>
In file 'inline-comments.php' change:
echo "<ul class=\"commentlist inlinecomments\">\n";
to
echo "<ul class=\"commentlist inlinecomments\" style='display:none;'>\n";
In file 'inc/p2.js' add this code at line 456:
var hidecomments = true;
Great! It works. Thanks!
Thank you! It was usefull.
yup - will proly lose it on the first upgrade, too!
But at least I know where to find it.
Thanks. Works great for me too.
I did it like this ...
inlinecomments.php
change
echo "<ul class=\"commentlist inlinecomments\">\n";
to
echo "<ul class=\"commentlist inlinecomments\" style=\"display: none;\">\n";
This makes comments hidden to begin with.
index.php
change
<a href="#" id="togglecomments"><?php _e('Hide threads', 'p2'); ?></a>
to
<a href="#" id="togglecomments"><?php _e('Show threads', 'p2'); ?></a>
This just changes the words at the top of the page.
So it says "Hide threads" to begin with.
p2.js
change
$("#togglecomments").click(function(){
hidecomments = !hidecomments;
var hideTxt = p2txt.hide_threads;
var showTxt = p2txt.show_threads;
if (hidecomments) {
commentLoop = false;
commentsLists.hide();
$(this).text(showTxt);
} else {
commentsLists.show();
$(this).text(hideTxt);
}
return false;
});
to
$("#togglecomments").click(function(){
hidecomments = hidecomments; // REMOVE !
var hideTxt = p2txt.hide_threads;
var showTxt = p2txt.show_threads;
if (hidecomments) {
commentLoop = false;
commentsLists.hide();
$(this).text(showTxt);
} else {
commentsLists.show();
$(this).text(hideTxt);
}
hidecomments = !hidecomments; // ADD THIS LINE
return false;
});
This makes the first click action to be 'showTxt'.
I can't find the code that actually replaces style="display: none;" with style="display: block;" but it works anyway.
I am now trying to exploit this understanding to...
Hide comments by default in single.php and have links like on Facebook.
e.g. Comment View Feedback (4)
Clicking Comments shows/hides the comment form.
Clicking View Feedback (4) shows/hides comments and includes a comment count.
Anyway, that is what I aim to achieve.
tjeastmond..
Great... It works..
@Luke: Thanks for the code modifications, exactly what I was looking for.
Cheers
Gene
This uses cookies to set a preference of open or closed, threads are closed by default. Just download the cookie plugin and link it in your header.
$("#togglecomments").click(function(){
var hideTxt = p2txt.hide_threads;
var showTxt = p2txt.show_threads;
if (hidecomments) {
commentLoop = false;
commentsLists.hide();
$.cookie('threads', 'hidden');
$(this).text(showTxt);
} else {
commentsLists.show();
$.cookie('threads', 'shown');
$(this).text(hideTxt);
}
hidecomments = !hidecomments;
return false;
});
var threads = $.cookie('threads');
if (threads == 'hidden') {
commentsLists.hide();
$(this).text(showTxt);
};forgot to add a var that changes the text to the correct line.
$("#togglecomments").click(function(){
var hideTxt = p2txt.hide_threads;
var showTxt = p2txt.show_threads;
if (hidecomments) {
commentLoop = false;
commentsLists.hide();
$.cookie('threads', 'hidden');
$(this).text(showTxt);
} else {
commentsLists.show();
$.cookie('threads', 'shown');
$(this).text(hideTxt);
}
hidecomments = !hidecomments;
return false;
});
var showTxt = p2txt.show_threads; // add this
var threads = $.cookie('threads');
if (threads == 'hidden') {
commentsLists.hide();
$("#togglecomments").text(showTxt); //add this
};This topic has been closed to new replies.