Sistem template NexaDom menyediakan mekanisme render yang fleksibel dengan dukungan multiple layouts dan device-specific templates. Sistem ini memungkinkan pengembang untuk mengelola tampilan berdasarkan device dan kebutuhan spesifik.
// Render template dasar
$this->render('index');
// Render dengan data tambahan
$this->render('dashboard', [
'user_name' => 'John Doe',
'role' => 'admin'
]);
// Render dengan return value
$content = $this->render('partial/header', [], true);
// Set layout spesifik
$this->setLayout('admin');
// Set device type untuk responsive template
$this->setDeviceType('mobile');
// Mendapatkan default template
$defaultTemplate = $this->getDefaultTemplate();
class YourController extends NexaController {
protected function init(): void {
parent::init();
// Setup device layouts
$this->setDeviceType('mobile');
// atau
$this->setDeviceType('tablet');
// atau
$this->setDeviceType('desktop');
}
}
templates/
├── desktop/
│ ├── layout.html
│ └── pages/
├── mobile/
│ ├── layout.html
│ └── pages/
├── tablet/
│ ├── layout.html
│ └── pages/
└── shared/
└── components/
file_templates
{content}
Welcome, {user_name}!
// Dalam Controller
protected function init(): void {
parent::init();
// Auto detect device
if ($this->isMobile()) {
$this->setDeviceType('mobile');
} elseif ($this->isTablet()) {
$this->setDeviceType('tablet');
} else {
$this->setDeviceType('desktop');
}
// Set default layout
$this->setLayout('main');
}
// Debug template resolution
$this->debugRequest();
// Check template existence
if ($this->isExists('dashboard', 'admin')) {
$this->render('dashboard');
}