costum field in comments
Posted: 24 July 2007 09:03 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  03-15-2007

I would like for users to enter a subject when the leave comments. Is there way to do this?
Besides the {comment} field, I couldn’t find a way to add a custom field. I could use another field like {location} for it, but that would work only for user who are not logged in as {location} will be filled with the info from the member set-up.
To keep it short, any ideas how to add a subject line to comments?

 Signature 

backpackingmalaysia.com ||| SAMA SAMA media service

- Be change you want to see in the world.-

Profile
 
 
Posted: 24 July 2007 09:13 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

Not without hacking- or creating an extension.  And I think you could do it with an extension (and adding an extra field to the exp_comments table).  As you say- the easy way would be to snag an existing field such as location- but it will be replaced by the member setting for members.  So if you don’t want to add an extra field, you could probably still use one of the existing ones if you use a hook to take over processing and avoid the replacement of data by logged in members.

So ‘out of the box’- it’s not doable.  But it wouldn’t be hard to work around with an extension.  Make sense?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 24 July 2007 09:25 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  03-15-2007

It does. I guess, the best way would be to add a “subject” field in the comments table. However, since I’ve never hacked into the EE System, I wouldn’t even know where to look for the script that writes into and reads from the comments table to add the subject. A little help here would be appreciated I before kill my system wink
Edit:
I did find the script that reads the comments in mod.comment.php, however I’m having troubling making sense of how to insert a new comment

 Signature 

backpackingmalaysia.com ||| SAMA SAMA media service

- Be change you want to see in the world.-

Profile
 
 
Posted: 24 July 2007 09:46 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

Hm- debates.  Well, I’d have to dig to come up with a really clean way to do it.  The easy way would be to hack mod.comments.php around line 2417:

if ($SESS->userdata('member_id') != 0)  
  
{
   
// If the user is logged in we'll reassign the POST variables with the user data
   
    
$_POST['name']  = ($SESS->userdata['screen_name'] != '') ? $SESS->userdata['screen_name'] : $SESS->userdata['username'];
    
$_POST['email'] =  $SESS->userdata['email'];
    
$_POST['url']   =  $SESS->userdata['url'];
    
$_POST['location'] =  $SESS->userdata['location'];
  
}


That replaces the posted values with the session data for a logged in member- comment out the one for location and it won’t get replaced.  I took a look at the preview- it’s not replaced at that point IF they’ve entered a location.  If they haven’t, it’s replaced by session info as well- so might need to comment out that bit if you’re using preview and they may leave the title blank.

Hacks are a pain to keep up, but it would be a simple one and would work.  To avoid the hack, I’d start with the ‘insert_comment_start’ and completely take over the submission- the extension docs would get you started on doing that.

I’m torn on which way I’d go- but if it was something I’d be doing for more than one site?  The extension would win out due to updating issues.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 24 July 2007 09:52 AM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33276
Joined  05-14-2004

Hey guys, I’ve moved this to how-to as it is far beyond the technical support forum.  Robin has been extremely nice to offer this solution, but I would like to point out that hacks are not officially supported, and since an extension can be built for this, I’d highly recommend using an extension instead. If you do not know how to do write an extension, you could post on our Job Board or hire someone from our Pro Network to help you out.

An extension would mean a clean upgrade path too, with a hack, you will need to track and re-implement the hack after each update.

 Signature 
Profile
MSG
 
 
Posted: 24 July 2007 10:01 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  03-15-2007

Hopefully, I didn’t create any tension between you here…. But thanks for the quick hack, Robin. That works for now. Since I only commented out a single line and it’s my only hack so far I should be able to keep track. Though, I will look into the extension matter once I got more time. Once again, I appreciate your help and Lisa please forgive Robin, it’s all my fault wink

 Signature 

backpackingmalaysia.com ||| SAMA SAMA media service

- Be change you want to see in the world.-

Profile
 
 
Posted: 24 July 2007 10:03 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33276
Joined  05-14-2004

Nope, no tension at all.  Robin is absolutely brilliant, but hacking is a bit beyond what we can officially offer or support down the line, so I wanted to make that clear in case you go forward with this. =)

Robin is wonderful and she’s way smarter about these hacks than I am - hacks scare me so I don’t personally touch them, mostly because I *always* forget to re-apply them and break my site.  =)

 Signature 
Profile
MSG
 
 
Posted: 24 July 2007 11:36 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23751
Joined  05-20-2002

LOL- yea, it’s all good.  Should have moved it over myself once we got into the actual ‘how to hack it’ bits- but I wandered off.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 01 April 2008 02:43 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Avatar
Total Posts:  23
Joined  02-18-2006

Did this ever become an extension? I’ve been Googling but haven’t found anything, and I also need custom comment fields.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66468 Total Logged-in Users: 35
Total Topics: 84862 Total Anonymous Users: 15
Total Replies: 455350 Total Guests: 178
Total Posts: 540212    
Members ( View Memberlist )