Jump to content
Daniel Schmitz

Acymailing plugin

Recommended Posts

Hi,

I know this is not related to code you did NOT create but it my be of interested for other users that use acymailing + jreviews. Right now the plugin has some "old" code in it so newsletter creation does not work, error is shown as in attachment. I have already asked to acymailing team to create a new version of plugin.

Error: Class "ConfigComponent" not found

Regards,
Daniel

erroracy.jpg

Edited by Daniel Schmitz

Share this post


Link to post

Hi Carl,

Just emailed with them yesterday regarding this issue. There did not start working on this. There are some problems creating a jreviews testing site on their end.

I will set up a testing site next week and provide access to acyba team and hopefully they can update the plugin soon.

Regards Daniel 

Share this post


Link to post

I believe that you can easily implement this yourselves using a JReviews 3 event listener for the "listing was first published event". All you need to do is define the event listener provider and add your listener. It goes in overrides and doesn't touch any core functionality.  You just need to use the code provided by AcyMailing to create the newsletter, etc.

1. First you need to create a new listener provider in overrides:

/templates/jreviews_overrides/events/providers/acymailing_listener_provider.php

I use the update event for testing, but it's commented below because I only want the newsletter code to execute on new listings

<?php
defined( 'MVC_FRAMEWORK') or die;

use Clickfwd\Listener\ListenerProvider;

class AcymailingListenerProvider extends ListenerProvider
{
	protected $listen = [
		'JReviews\Events\ListingWasFirstPublished' => [
			'JReviews\Listeners\CreateAcymailingNewsletter',
		],
		'JReviews\Events\ListingWasUpdated' => [
			// 'JReviews\Listeners\CreateAcymailingNewsletter',
		],
	];
}

2. Then you create the AcymailingListenerProvider listener that will execute when the ListingWasFirstPublished event is triggered.

/templates/jreviews_overrides/events/listeners/create_acymailing_newsletter.php

The code below is just for illustration purposes to help you get started.

<?php
namespace JReviews\Listeners;

defined( 'MVC_FRAMEWORK') or die;

use JReviews\Listeners\Traits\ListenerSetting;
use Clickfwd\Listener\QueueableListener;
use League\Event\EventInterface;

\S2App::import('ListenerTrait','listener_setting','jreviews');

class CreateAcymailingNewsletter extends QueueableListener
{
    use ListenerSetting;

	protected $queue = false;

     /**
     * Execution delay in seconds
     * @var int
     */
    protected $queue_delay = 5*60;

    public function handle(EventInterface $event)
    {
		$listing = $event->getListing();

		if ( $listing )
		{          
          		if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
			 	echo 'This code can not work without the AcyMailing Component';
			 	return false;
			 }
			 
			//We create the Newsletter element that we will save in the database.
			//You can use all fields from the database the same way we do it with subject and body.
			 
			$mail = new stdClass();
			//Subject of your Newsletter
			 $mail->subject = $listing['Listing']['title'];
			//Body of your Newsletter... the text version will be automatically generated from this html version.
			 $mail->body = $listing['Listing']['summary'].$listing['Listing']['description'];
			//ID of the template attached to this Newsletter so the CSS defined in that AcyMailing template will be applied to your Newsletter.
			$mail->tempid = 4;
			 
			$mailClass = acymailing_get('class.mail');
			 
			//the save function returns you the ID of the inserted Newsletter so you can then use it to insert e-mails in the queue.
			$mailid = $mailClass->save($mail);          
		}		
    }
}

3. Clear the file registry in JReviews so it can recognize the new files.

I copied the acymailing code directly from their dev docs so I don't know if that will work as is.

Share this post


Link to post

Hi Daniel & Alejandro

Thank you both for your responses.

I am in touch with Acyba and have pointed them to this forum post.  I have also offered them access to CapeInfo's development domain for testing purposes.

Kind regards, Carl

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Please refer to our Privacy Policy.