Search

Awesome to see the ETM is still put to good use! Luckily the issue you are getting is quite easy to fix:

Frontend::instance()->Page()->_param

Gets the params that are attached to the page. The params in the pool are only attached after each datasource has run, so the $etm-entry-id param is simply not yet there.

You most likely have something like this for a grab function definition (depending on your version):

public function grab(&$param_pool=NULL){

Now, this $param_pool variable will contain the etm-entry-id.

Thank you for your reply. That makes a lot of sense I've added this code below but it comes up blank.

$etmentryid=$param_pool['etm-entry-id'];

If I set the param above it works e.g.;

$param_pool['etm-entry-id']='40';
  $etmentryid=$param_pool['etm-entry-id'];

I have the follow construct above my execute function;

public function __construct(array $env = null, $process_params=true){
        parent::__construct($parent, $env, $process_params);
        $this->_dependencies = array(); 
}


public function execute(array &$param_pool = null) {

  $result = new XMLElement($this->dsParamROOTELEMENT);      
  $param_pool['etm-entry-id']='40';
  $etmentryid=$param_pool['etm-entry-id'];

  ...

}

Do I need to call something in a different order or change the dependencies at all? Sorry I'm pretty new to this so I'm just getting to grips with it. thanks again for your help

I am not completely sure what you are trying to do here, but if the event is attached to the same page the datasource is attached to, the event should run before the datasources, so the $param_pool should be populated with the etm-entry-id. There should be no need for the $param_pool['etm-entry-id']='40'; line.

In the form you use to trigger the event, could you set the action to ?debug? That way we can see if the event is running at all, and maybe catch any errors that stop the logic from working.

thanks for your help @creativedutchmen, my apologies for the code;

$param_pool['etm-entry-id']='40';

this was purely for my testing purposes to make sure I had the code right to access the param_pool and should have been removed.

I have a page - {$root}/paypal (notify url) - this has the paypalpaymentsipn event attached, which contains the following code;

#Email Template Code
            $email    = Email::create();
            $template = EmailTemplateManager::load('payment-received');
            $template->addParams(array(
                "etm-entry-id" => $entry_id
            ));
            $xml = $template->processDatasources();
            $template->setXML($xml->generate());
            $template->parseProperties();
            $properties = $template->getParsedProperties();
            $content    = $template->render();
            if (!empty($content['subject'])) {
                $email->subject = $content['subject'];
            }
            if (!empty($content['recipients'])) {
                $email->recipients = $content['recipients'];
            }
            if (isset($content['reply-to-name'])) {
                $email->reply_to_name = $content['reply-to-name'];
            }
            if (isset($content['reply-to-email-address'])) {
                $email->reply_to_email_address = $content['reply-to-email-address'];
            }
            if (isset($content['plain']))
                $email->text_plain = $content['plain'];
            $email->send();

Also on the {$root}/paypal page I have my custom data source attached, the one trying to access the $param_pool.

I then have an email template called 'payment received' with the custom data source mentioned above as its source.

The email is being sent and I can access $etm-entry-id from the xslt email template but I can't access it from within the data source.

I just can't see where I am going wrong. My apologies if it is something simple! I am struggling to debug the form because it redirects to paypal and all of the action is on the notify url page.

bump...

Please can anyone spot where I am going wrong? As far as I can see the event is attached to the correct page and the email template is set up correctly with the custom data source.

The event fires because the email is sent out. The data source is working because if I hard code the filter value the email has the correct content from the database.

It is just the $etm-entry-id I am unable to access in the custom data source. The $param_pool just appears to be empty.

My apologies for the lack of knowledge, I am new to all of this custom coding so it's taking a little time to get my head around it.

Thank you in advance for your help.

Hmm, I am a bit out of ideas to try here. If you want I could take a look at the actual install? Drop me an email if you do: huib@<username>.com

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