Search

Slowly clunking my way toward Symphonian proficiency, I also am puzzling over Events and saving comments.

I am modfying a vanilla install of Symphony where there is a Comments section/datasource and there is also a Comments Event – but they are not tied together, right? The Save comments event saves anything that is pulled out of form into a section designed for it, correct?

I have noticed the Save Comments event will be processed continuously, if the page is refreshed. There appears to be no error checking to ensure the data has not already been sent? Is there an easy way of triggering checking so that the database doesn’t get packed with repeated attempts?

Is there a way of triggering two events? Saving the data to a section and sending a e-mail to me to let me know a comment has been submitted, so that I can approve it?

I had a peek into “event.save_comment.php” but realize I would need to go deeper into the php underpinnings of Symphony than I feel comfortable doing.

(Fred, I forked this from the other thread since it’s something new.)

Is there a way of triggering two events? Saving the data to a section and sending a e-mail to me to let me know a comment has been submitted, so that I can approve it?

There is a filter to send emails. Just add it to your event. Saving will update the documentation for the event with instruction how to use the filter.

I am modfying a vanilla install of Symphony where there is a Comments section/datasource and there is also a Comments Event – but they are not tied together, right? The Save comments event saves anything that is pulled out of form into a section designed for it, correct?

An Event is tied to a Section, in the same way that a Data Source is tied to a Section.

I have noticed the Save Comments event will be processed continuously, if the page is refreshed

Yes indeed. Refreshing the form POST in your browser will resubmit the form (to the event). That’s normal behaviour for web forms. To prevent this occurring you should send a redirect hidden field containing the URL to redirect to if the event submits successfully. A hard redirect will prevent a refreshing triggering the event again.

Is there a way of triggering two events? Saving the data to a section and sending a e-mail to me to let me know a comment has been submitted, so that I can approve it?

Two events can be fired, but you need to customise the PHP. Instead, I recommend you use the “Send Email” filter, look out for it in the Filters list in the Event editor. See the extra HTML it adds to the example markup, where you specify the Author username to which the email should be sent.

@klaftertief, @nickdunn Thanks for responding.

@nickdunn Thanks for forking my question, I am never quite sure how off topic things need to be to warrant a new thread.

Regarding saving the comment and sending and e-mail, I was slightly confused by text:

This event will not be processed if any of these rules return true.

Looking at the additional information which appears when choosing the Send e-mail filter rule, this happens after the comment information is saved so is basically what I want. I have change the comments section to have a publish field which the administrator will act on.

Refreshing the form POST in your browser will resubmit the form …

A hard redirect is takes people off the the page. When developing in the past I scripted PHP to register a cookie and check for new input when the form was resubmitted, saving the user a trip out and back to the page. I suppose I can develop some sort of validation using javascript, but this will be client-dependant. It has been about five years since I did anything serious with PHP, so I may settle for a redirect.

The redirect will only happen after a successful save. When there are any errors during saving, the event returns XML with error messages.

You can use the Dynamic Event Redirect Extension for more advanced redirects. And there is nickdunns Form Control utility that makes your life for form creation easier.

@klaftertief Thanks, both resources look helpful.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details