basePresenter run code before other presenters are called

Notice: This thread is very old.
simonjcarr
Member | 28
+
0
-

I want to put some code in my basePresenter that runs at every page request, how do I do it?

CZechBoY
Member | 3608
+
0
-

Implement startup method with your custom code. Dont forget for calling parent::startup().

simonjcarr
Member | 28
+
0
-

@CZechBoY Thanks for the response. I have the following code in my BasePresenter.php file. But nothing happens. I would expect a white screen with just “I am here”.

Any idea what I might be doing wrong?

namespace App\Presenters;

use Nette;
use App\Model;

/**
 * Base presenter for all application presenters.
 */


abstract class BasePresenter extends Nette\Application\UI\Presenter {

    protected function startup() {
	parent::startup();
	echo "I am here";
	exit;
    }


}
Jan Endel
Member | 1016
+
+1
-

Hello @simonjcarr, do you extend your BasePresenter in your leaf Presenter?

Check especially the namespaces.

simonjcarr
Member | 28
+
0
-

@JanEndel Thanks. That was the issue, I was not extending BasePresenter

It works now.

Thanks