Nette Modules – correct setup?

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

I see in the Documentation that Nette can have modules so that you can logically separate different parts of the your code.

Given the directory structure below, would the class below be correct and if so, how would I refer to that in the URL. At the moment I am getting the following error.

Cannot load presenter ‘Adminmodule’, class ‘App\Presenters\AdminmodulePresenter’ was not found.

My Current Setup

nette-blog/
    app/                ← directory with application
        AdminModule/    ← Admin module
            presenters/ ← its presenters
				UsermanagerPresenter.php
            templates/  ← its templates

        FrontModule/    ← Front module
            presenters/ ← its presenters
            templates/  ← its templates

        ...
namespace AdminModule;
use Nette;
use App\Model;


class UsermanagerPresenter extends \Nette\Application\UI\Presenter
{

	public function renderDefault()
	{
		$this->template->anyVariable = 'any value';
	}

}

Last edited by simonjcarr (2015-10-28 21:01)

Milo
Nette Core | 1175
+
0
-

Presenter class name is not tied to a directory structure. The are something called mapping between presenter name and class name. Default in config.neon is ∗: App\∗Module\Presenters\∗Presenter which means: “For any presenter () use such mask (App\∗Module\Presenters\∗Presenter).” So:

# Module 'Blog', presenter 'Admin'
namespace App\BlogModule\Presenters;

class AdminPresenter extends ...
{}
simonjcarr
Member | 28
+
0
-

Thank you,

I had the namespace wrong in my file and then also found the url syntax seems a bit unusual using a dot (.) to seperate the module and the presenter (http://localhost/….usermanager)