2

I am developing a module which resides in the third_party directory of my expression engine install, which includes a public method which sends an email when called via cron. Currently the only way I can think to call this method is by setting up an action and calling it via the url.

Something like this;

http://my.domain/?ACT=52

This seems to be confirmed here as a valid approach.

The problem with this is that it breaks as soon as the module gets re-installed, as the action id will be regenerated.

So then I thought about making a template, which has an embedded call to my module method, and visiting the url of this template from my cron job. This is ok, but I don't like the idea of using templates for something that is not in any way a view.

What I would like to do, bearing in mind EE is built on an MCV framework, is use the codeigniter routing to call it. Something like;

/third_party/my_module/my_controller/my_email_method

But I don't know if this is possible, nor what the form of the url would be if it were possible.

1

You need a to create a plugin tag that would essentially be an alias for the action id. You don't need a controller, as the controller would be the EE template, and you just need a tag to execute an arbitrary method.

You may want to look into Postmaster. The amount of time you would spend rewriting the functionality would need would be far less than the cost of Postmaster. https://objectivehtml.com/postmaster

However, if you are just wanting your own solution so you can maintain it, Postmaster definitely does everything you need from a logic perspective. It has CRON based notifications using ACT id's, and even has plugin tags, so really any combination of emails are possible. So you can be sure that everything you are trying to do is relatively easy to accomplish with EE. The nice thing about Postmaster however, if you can send emails with any service, so it will scale to your needs in the future (should they grow and change).

| improve this answer | |
  • You could also create an extension which looks for a specific URL segment and routes it to the right place. – Jeremy Gimbel Sep 25 '13 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.