Admin modul config.neon struktura
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Lukass445
- Člen | 19
Zdravím,
mám takúto adresárovú štruktúru:
App
config/
...
model/
...
presenters/
AdminModule/
ModuleBasePresenter.php
HomepagePresenter.php
BasePresenter.php
HomepagePresenter.php
...
router/
templates/
AdminModule/
Default/
default.latte
@layout.latte
a takto vyzerá môj config.neon:
parameters:
php:
date.timezone: Europe/Prague
nette:
application:
errorPresenter: Error
mapping:
*: App\*Module\Presenters\*Presenter
Admin: ???????????
session:
expiration: 14 days
services:
- App\Model\UserManager
- App\RouterFactory
- kde neviem ako korektne namapovať cestu (???????????) k admin presenterom/.latte súborom.
ModuleBasePresenter.php :
<?php
namespace App\AdminModule\Presenter;
use Nette,
App\Model,
App\Presenters\BasePresenter;
/**
* ModuleBasePresenter.
*/
abstract class ModuleBasePresenter extends BasePresenter
{
/** @var Nette\Database\Context */
private $database;
public function __construct(Nette\Database\Context $database)
{
$this->database = $database;
}
}
a App\presenters\AdminModule\HomePagePresenter.php
<?php
namespace App\AdminModule\Presenter;
use Nette,
App\Model;
class HomepagePresenter extends ModuleBasePresenter
{
/** @var Nette\Database\Context */
private $database;
public function __construct(Nette\Database\Context $database)
{
$this->database = $database;
}
public function renderDefault()
{
$this->template->prem = 100;
}
}
- Taktiež neviem ako sa správne v linke odkázať na tento admin modul, respektíve jeho defaultnú stránku. Pri pokusoch o správne nadefinovanie tejto cesty v mapping: stále dostávam takýto error:
Cannot load presenter ‚Admin‘, class ‚App\Presenters\AdminPresenter‘ was not found in ‚/home/u417629429/public_html/web/app/presenters/AdminPresenter.php‘
- skúšam domena.com/admin
Za každú pomoc vopred ďakujem.
Editoval Lukass445 (4. 12. 2014 21:05)
- Lukass445
- Člen | 19
@Azathoth nie, nefunguje
router:
<?php
namespace App;
use Nette,
Nette\Application\Routers\RouteList,
Nette\Application\Routers\Route,
Nette\Application\Routers\SimpleRouter,
Nette\Utils\Strings;
/**
* Router factory.
*/
class RouterFactory
{
/**
* @return \Nette\Application\IRouter
*/
public function createRouter()
{
$router = new RouteList();
$router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
return $router;
}
}
je v defaultnom stave
- David Matějka
- Moderator | 6445
@Azathoth to nepouzije admin modul, spravne je to
$router[] = $adminRouter = new RouteList('Admin');
$adminRouter[] = new Route('/admin/<presenter>/<action>[/<id>]', ...);