boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

possibility to have posts with and without a comment

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sat Jul 26, 2003 4:44 pm    Post subject: possibility to have posts with and without a comment Reply with quote

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 8Cool:
/* 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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
valentine



Joined: 27 Jul 2003
Posts: 7

PostPosted: Sun Jul 27, 2003 6:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sun Jul 27, 2003 6:30 pm    Post subject: problem with older messages Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
valentine



Joined: 27 Jul 2003
Posts: 7

PostPosted: Sun Jul 27, 2003 6:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sun Jul 27, 2003 6:52 pm    Post subject: problem with default 1 or 0 Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sun Jul 27, 2003 6:56 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
valentine



Joined: 27 Jul 2003
Posts: 7

PostPosted: Sun Jul 27, 2003 7:14 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sun Jul 27, 2003 7:50 pm    Post subject: Reply with quote

You've edited the UPDATE query?
_________________
--
Anything About Everything (in Dutch)
http://www.veel-in-een.nl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
valentine



Joined: 27 Jul 2003
Posts: 7

PostPosted: Sun Jul 27, 2003 8:20 pm    Post subject: Reply with quote

yup. checked it again and still the same thing.
Back to top
View user's profile Send private message Visit poster's website AIM Address
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sun Jul 27, 2003 8:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
valentine



Joined: 27 Jul 2003
Posts: 7

PostPosted: Sun Jul 27, 2003 9:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
evelyne



Joined: 12 Dec 2002
Posts: 23
Location: Delft - The Netherlands

PostPosted: Sun Jul 27, 2003 9:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
valentine



Joined: 27 Jul 2003
Posts: 7

PostPosted: Sun Jul 27, 2003 10:00 pm    Post subject: Reply with quote

thank you! everything is working perfectly now. =^_^= you're amazing!
Back to top
View user's profile Send private message Visit poster's website AIM Address
girlvsherself



Joined: 29 Aug 2003
Posts: 2

PostPosted: Fri Aug 29, 2003 7:41 am    Post subject: Reply with quote

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
View user's profile Send private message
girlvsherself



Joined: 29 Aug 2003
Posts: 2

PostPosted: Sat Aug 30, 2003 6:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group