Search

Is there a way to trigger an event without submiting a form?

I basically want to use the email template manager for a newsletter and am thinking about setting up a cronjob to call a script that executes the event.

Thanks a lot!

Yep. Open the event PHP file and you'll see an if condition in the load() method that checks the $_POST array, and calls __trigger if a condition is met. Remove the condition and always execute __trigger and it'll do it on every page load.

Is there a way to trigger an event without submiting a form?

The trigger function is loaded on page load:

    public function load(){
        if(isset($_POST['action']['message'])) return $this->__trigger();
    }

You could simply edit it:

    public function load(){
        return $this->__trigger();
    }

If you do make edits to events, it's a good idea to not allow the Symphony event editor access:

    public static function allowEditorToParse(){
        return false;
    }

I'm slow.

Yes, but much more verbose!

If you do make edits to events, it's a good idea to not allow the Symphony event editor access:

public static function allowEditorToParse(){
    return false;
}

I didn't know about this bit. Thanks @Lewis.

Great guys!

Thank you loads!!!

Okay, another question, is there an easy way to trigger an event when creating a new entry to a section in the backend?

Cheers!

You will need to write an extension which subscribes to the EntryPostCreate and EntryPostEdit delegates. From here you can probably instantiate your event and run it.

The simplest example I can think of is the Pingomatic extension which pings the pingomatic service when you have created any entry in the backend. You'll want to add additional checks in there to make sure you only run your event when you have created an entry in a certain section only.

What are you trying to implement?

I'll install the pingomatic extension and look into it. Thanks for the tip!

Basically I want to use the Email Template Manager to send out newsletters... Although I might run into trouble once there are 1000 recipients or more. But until that happens michael-e will hopefully have updated the Newsletter extension ;)
So anyways, once an entry is created in the backend the event triggers and can read the content just stored in the section (as the main article for the newsletter).

Basically I want to use the Email Template Manager to send out newsletters... Although I might run into trouble once there are 1000 recipients or more.

You will definitely run into trouble, even with 100 recipients. I bet that your PHP process will time out, because you won't be able to send so many emails through SMTP fast enough. Maybe your best bet would be to use the Sendmail socket (because it can spool emails to disk), but again that is by no means robust using so many recipients. In this case Sendmail and DNS must be configured right! I do not recommend this.

But until that happens michael-e will hopefully have updated the Newsletter extension ;)

Huib (a.k.a. creativedutchmen) and I are working on this. Without making any promises, I expect it to be released within the next 4 weeks or so. Setup and usage will be much simpler than today. There will be virtually no limit regarding the number of recipients.

So if you have some time left, wait for Email Newsletters 2.0. If you are in a hurry, try to implement the current version.

okay thanks! perhaps have several templates filtering the datasources differently and sending 100 emails at a time...

looking forward to the new Email Newsletter :)

What if i want to silently submit some data to event when user enters the page and i don't want to flood url with POST's data?

ajax request doing the job, but it's not robust. if only i could access xml data inside custom event.. (and know how to interpret it with php!)

hi there, i'm trying to trigger an event on page load, using the technique above, but with no luck. i'm ending into error.

on that page i have this markup

<form id="subscribe" method="post" action="register-user">
    <input name="fields[username]" value="someUsername" type="hidden" />
    <input name="fields[email]" value="someEmail" type="hidden" />
    <input name="redirect" type="hidden" value="{$root}" />
</form>

i removed validation from section, but this doesn't solve anything. having in mind that this thread is dated May 2011, i'm wondering if is still supported in v 2.3.2

thank you

Attachments:
Screen shot 2013-05-07 at 12.09.02 AM.png

No form is submitted, so it's complaining that there is no fields array. You need to submit the form to a default event using javascript.

I see. Thank you :d

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