View previous topic :: View next topic |
Author |
Message |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sat Jul 26, 2003 4:44 pm Post subject: possibility to have posts with and without a comment |
|
|
People were asking if it was possible to stop comments whenever they wanted. I've got a little hack working now, which gives the writer the choice.
You can see it at work at a friends log (I created the hack for this person)
http://www.ejzonjee.nl
I've written an instructionfile, which can be found at:
http://www.veel-in-een.nl/comments_hack.txt
It could have be cleaner code, but I was a bit in a hurry when I did the hack.
Hopefully it will be helpful for some of you! Please send me your url when you've implemented this hack. Probably I will find some time to document some other hacks I did also.
Added some extra code:
Edit b2comments.post.php
Find (line 8 :
/* end flood-protection */
just below, add:
$query = "SELECT * FROM $tableposts WHERE ID='$comment_post_ID'";
$result = mysql_query($query);
$ar=mysql_fetch_array($result);
if ($ar['post_comment']=="0"){
die("comments are disabled for this post");
}
Last edited by evelyne on Sun Jul 27, 2003 6:55 pm; edited 1 time in total |
|
Back to top |
|
 |
valentine
Joined: 27 Jul 2003 Posts: 7
|
Posted: Sun Jul 27, 2003 6:26 pm Post subject: |
|
|
well, i've tried to use it (thank you!), but i've run into a bit of a problem. although the row's default is set to "1," all my previous entries now have comments disabled. when i try to edit the post and set the comments to "on," it defaults back to "off" without updating the post. =^^=; any idea what might be happening?
http://www.damaged-angel.net
maybe if i play with it some more i'll understand what's going on. |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sun Jul 27, 2003 6:30 pm Post subject: problem with older messages |
|
|
When you look within your table, do all the older messages have the post_comment set on 1 or zero? _________________ --
Anything About Everything (in Dutch)
http://www.veel-in-een.nl |
|
Back to top |
|
 |
valentine
Joined: 27 Jul 2003 Posts: 7
|
Posted: Sun Jul 27, 2003 6:49 pm Post subject: |
|
|
they have it set to zero, although i double checked and the default is 1. not sure what's going on, especially since it won't save the changes i made. i don't have a lot of experience with mysql and php, so perhaps that's the problem...
unless you know what's going on, i just cheated and changed the code to use 0 as the "on" and 1 as the "off." seems to be working well enough so far. =^^=; |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sun Jul 27, 2003 6:52 pm Post subject: problem with default 1 or 0 |
|
|
If you set no comments to 1 and 0 is allowing off comments, make sure you set the default from post_comment to 0 (unless you more likely want to have comments off).
Your solution to switch the 0 and 1 is a good one. It doesn't matter which one is which, you only have to make sure you remember what you've done. _________________ --
Anything About Everything (in Dutch)
http://www.veel-in-een.nl |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sun Jul 27, 2003 6:56 pm Post subject: |
|
|
Make sure you also edit b2comment.post.php like this:
$query = "SELECT * FROM $tableposts WHERE ID='$comment_post_ID'";
$result = mysql_query($query);
$ar=mysql_fetch_array($result);
if ($ar['post_comment']=="1"){
die("comments are disabled");
} _________________ --
Anything About Everything (in Dutch)
http://www.veel-in-een.nl |
|
Back to top |
|
 |
valentine
Joined: 27 Jul 2003 Posts: 7
|
Posted: Sun Jul 27, 2003 7:14 pm Post subject: |
|
|
looking at this some more, i think the problem must be with editing the posts. no matter whether a new post has comments set on or off, i can't change them afterward. it will default to whatever i set it to the first time. is it perhaps something different in my b2 file versions? |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sun Jul 27, 2003 7:50 pm Post subject: |
|
|
You've edited the UPDATE query? _________________ --
Anything About Everything (in Dutch)
http://www.veel-in-een.nl |
|
Back to top |
|
 |
valentine
Joined: 27 Jul 2003 Posts: 7
|
Posted: Sun Jul 27, 2003 8:20 pm Post subject: |
|
|
yup. checked it again and still the same thing. |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sun Jul 27, 2003 8:26 pm Post subject: |
|
|
Ok, changing from one to zero isn't possible I think? Make sure the row is NOT set to 'NOT NULL' then. Make sure it will be 'NULL' _________________ --
Anything About Everything (in Dutch)
http://www.veel-in-een.nl |
|
Back to top |
|
 |
valentine
Joined: 27 Jul 2003 Posts: 7
|
Posted: Sun Jul 27, 2003 9:02 pm Post subject: |
|
|
hmm. well, i tried wiping the files and starting the hack over, and this is what i came up with. i can now edit previous posts to have comments on or off, everything else works fine, except...the default for all entries is still set to "off." changing the row to "null" or "not null," "1" or "0," does not change this. i suppose my option is to change every post by hand?
i really appreciate your help in this, by the way. =^_^= |
|
Back to top |
|
 |
evelyne
Joined: 12 Dec 2002 Posts: 23 Location: Delft - The Netherlands
|
Posted: Sun Jul 27, 2003 9:31 pm Post subject: |
|
|
You could try to edit the whole table by entering this SQL-query:
UPDATE 'b2posts' SET post_comment='1' WHERE post_comment='NULL';
This way everything is set to 1.
Another option is that all your older posts have a post_comment set to NULL, the newer ones will have a 0 or a 1. If so, this will also work:
edit index.php, where it says:
if ($ar2['post_comment']=="1"){
edit it and make sure it says:
if ($ar2['post_comment']=="1" || $ar2['post_comment']=="NULL"){
(or if you're still working with zero=on set it to:
if ($ar2['post_comment']=="1" || $ar2['post_comment']=="0"){
) _________________ --
Anything About Everything (in Dutch)
http://www.veel-in-een.nl |
|
Back to top |
|
 |
valentine
Joined: 27 Jul 2003 Posts: 7
|
Posted: Sun Jul 27, 2003 10:00 pm Post subject: |
|
|
thank you! everything is working perfectly now. =^_^= you're amazing! |
|
Back to top |
|
 |
girlvsherself
Joined: 29 Aug 2003 Posts: 2
|
Posted: Fri Aug 29, 2003 7:41 am Post subject: |
|
|
hi. so i'm really new to this b2 stuff and on the first part of your instructions it says:
Quote: | edit your b2posts table:
add an extra row named post_comment, make it a tinyint(2), NOT NULL, default '1' (this way the comments will be on as default)
|
well, in what file do i do that?
thanks =] |
|
Back to top |
|
 |
girlvsherself
Joined: 29 Aug 2003 Posts: 2
|
Posted: Sat Aug 30, 2003 6:46 am Post subject: |
|
|
ok so never mind that pervious post of mine. i figured out that i needed to use phpmyadmin for that.
this hack works great. it worked right the first time too =].
thanks!!! |
|
Back to top |
|
 |
|