EE newbie question - additional processing to comments in blog after submit
Posted: 20 November 2008 04:40 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  01-23-2006

I want to issue a sql statement in php after a successful comment posting but can’t figure out where to do that. Both the $IN and $OUT variables do not have enough information, as well as the $_POST values are empty when the page comes back online.  I have been editing the blog/detail template, which is used to show the individual blog post and the comments.
The return parameter is ignored in the statement below.
{exp:comment:form weblog=“blog” preview=“blog/detail”}

To restate:  EE is saving the comment correctly, and reloading the detail page with the new comment.

I want to issue a sql statement via php when the comment is saved to the db, and not upon each page load.

Anyone have any ideas on how to go about this?

thanks

Moved to Extensions: Technical Assistance by Moderator

Profile
 
 
Posted: 21 November 2008 12:21 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  430
Joined  02-26-2008

I’m not sure I understand correctly.  Are you saying you want to load the new comment on the page without refreshing?

Profile
 
 
Posted: 21 November 2008 11:11 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  01-23-2006

Sorry if I wasn’t clear.

I want to issue a sql query after a comment is posted.  I can’t find a way to test for a successful comment submission condition in the blog detail template. 

Here is the process:

1. user views the blog detail page
2. user enters comment - previews it - submits it
3. the blog detail page is reloaded with the users comment in the list

I want to place a piece of code on the blog details page, that will only run when a new comment is posted, on step 3.

I have tried to trap/test for any $_POST variables, but they are blank after the blog details page reloads with the new comment in step 3.  I have also checked the $IN variables, and I can’t find any method to determine if the blog details page is loading as in step 1 or in step 3 (a result of a comment being submitted/saved)

Can anyone point me in the right direction for adding an post comment submission function?

thanks

Profile
 
 
Posted: 24 November 2008 04:39 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  01-23-2006

Anyone have a quick how to implement an extension hook?

http://expressionengine.com/developers/extension_hooks/comment_form_end/

This hook might be what I need.

Profile
 
 
Posted: 24 November 2008 04:41 PM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12755
Joined  04-29-2002

fodney, I don’t have an answer for you, but I’m going to move this to the Extensions forum.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 24 November 2008 05:06 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  01-23-2006

Thanks for the move.

I guess I have more questions.

1.  Is it possible to call this hook from a template, the blog/detail template in particular?  How?

2.  Do I need to modify the mod.comment.php to edit this hook?  I am missing something with how EE expects me to access the hook.

I have php enabled on the blog/detail template, I also have it set as input not output.

When I echo the $EXT global in the template, I don’t see that this hook is active. 

I know that I am missing most of what needs to happen here.  Can anyone enlighten me?  I want to call a function upon successful completion of a comment. 

If there is an easier approach, please let me know, otherwise I was just going to hack the mod.comment.php to perform as required in this instance.

thanks

Profile
 
 
Posted: 25 November 2008 09:15 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  785
Joined  07-18-2006
fodney - 24 November 2008 05:06 PM

Thanks for the move.

I guess I have more questions.

1.  Is it possible to call this hook from a template, the blog/detail template in particular?  How?

2.  Do I need to modify the mod.comment.php to edit this hook?  I am missing something with how EE expects me to access the hook.

I have php enabled on the blog/detail template, I also have it set as input not output.

When I echo the $EXT global in the template, I don’t see that this hook is active. 

I know that I am missing most of what needs to happen here.  Can anyone enlighten me?  I want to call a function upon successful completion of a comment. 

If there is an easier approach, please let me know, otherwise I was just going to hack the mod.comment.php to perform as required in this instance.

thanks

Hi Fodney:

1: No you can’t call extension hooks from templates. You have to build an actual extension to call an extension hook.
2: No!  Definitely don’t go modding any EE files! That leads down an ugly slippery slope because any upgrades will break your site!  The extension system is set up to allow you to do the kind of post-processing you’re talking about without having to go modifying EE files themselves.

Have you gone through the extension development tutorial? That would be a great way to learn about how extensions work and help you towards your goal.

Profile
 
 
Posted: 25 November 2008 10:04 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23744
Joined  05-20-2002

Morning fodney- and yep, an extension is definitely the way to go.  Let’s see- best thing to do when you’re learning is to copy from a good example- Comment spam prevention at least relates to comments, and Paul wrote it so you know the code base is a good one for inspiration.

I suspect it uses an earlier hook than you need- it gets the post data and does some checks on whether the comment should be allowed.  You need to snag in a bit later than that- AFTER the comment has been successfully entered.

So- insert_comment_end looks like a good option.  Everything is done by that point and if they got that far, a comment was added. 

So- take a look at the spam prevention extension for some ideas, and the extension development docs for some more ideas.

This is a good one to start with- it really should be fairly simple.  (And once you do this one- could write one to handle the same thing for entry posting.)

That help?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 27 November 2008 09:30 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  497
Joined  01-23-2006
Brian M. - 25 November 2008 09:15 AM

Hi Fodney:

1: No you can’t call extension hooks from templates. You have to build an actual extension to call an extension hook.
2: No!  Definitely don’t go modding any EE files! That leads down an ugly slippery slope because any upgrades will break your site!  The extension system is set up to allow you to do the kind of post-processing you’re talking about without having to go modifying EE files themselves.

Have you gone through the extension development tutorial? That would be a great way to learn about how extensions work and help you towards your goal.

Yeah, I went through the tutorial, but I have so little experience with EE conventions it was just easier to modify the two files needed.  Thanks for the reply, and I completely understand the warnings and agree, writing an extension, or two in this case, would be the best solution, unfortunately the budget doesn’t allow for the added complexity.

My mod is super simple and easy, that I will be able to move it forward upon upgrades to the comments mod or the forums core.  It seemed to be the less complex solution, adding 2 lines of code to each file (the include and the function call), in the specific hook sections, was quick, simple and painless.

thanks

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: 66389 Total Logged-in Users: 46
Total Topics: 84714 Total Anonymous Users: 19
Total Replies: 454688 Total Guests: 190
Total Posts: 539402    
Members ( View Memberlist )