Problem with sort hook


#1

Hi everyone,

I created a hook to execute a plugin after a page becomes visible. The plugin send an email with the page information (Like a newsletter).

My problem is that in localhost runs correctly but in my client server when I sort the page, kirby starts to load few minutes and the email doesn’t send. In both cases I’m using SMTPMailer with the same connection info.

This is the code of the hook:

        kirby()->hook('panel.page.sort', function($page) {
    	$templates = array(
    		'default',
    		'new',
    		'course',
    		'depart-proyectsarticle'
    	);
    	$template = $page->template();

    	if(in_array($template, $templates)){
    		if($template == 'default'){
    			$template = $page->parent()->parent()->template();
    		}

    		intranetNewsletter($template, $page); <-- this is the plugin

    	}
    });

The error could be the permissions of the files? Or because there are a plenty of pages in content? I don’t know if those things are the problem.


#2

Where do you define your hook, in the config? It won’t know your plugin method then. I’d configure the hook in the plugin itself.


#3

I tried it and it does not run. I tried to move the plugin code on the hook and it does not work either


#4

Oh, another user with two profiles!

What does your plugin code do?


#5

I found the error. Is the plugin. The hook runs correctly, thanks!

The plugin sends an email but only runs in my computer (I don’t understand why, I’m working in it)