=== Visual Test: Template Wrapping ===
BEFORE (Old Pattern - Templates manually included header/footer):
======================================================================
My Studies
This is the content area only.
======================================================================
AFTER (New Pattern - Templates contain only content):
======================================================================
My Studies
This is the content area only.
======================================================================
RESULT: Presenter.render() automatically wraps with:
1. → Adds DOCTYPE, ,
,
2. → Adds navigation bar
3. [TEMPLATE CONTENT] → Your template's section
4. → Adds footer, ,
BENEFITS:
✅ Templates focus on content only
✅ No manual header/footer includes needed
✅ Consistent layout across all pages
✅ No risk of duplicate headers/footers
✅ Easy to change site-wide layout
FILES UPDATED:
✅ App/Presentation/Presenter.php - Added auto-wrapping to render()
✅ App/Presentation/Studies/*.php - Removed manual includes
✅ App/Presentation/Pages/*.plates.php - Removed manual includes
✅ App/Routes/Controllers/*.php - Added 'title' to data arrays
CONTROLLER PATTERN:
----------------------------------------------------------------------
public function list($app, $request) {
$studies = $app->study->getListOfActiveStudies($userId);
return [
'template' => 'Studies/list',
'data' => [
'studies' => $studies,
'title' => 'Studies List' // ← Title passed to Presenter
]
];
}
----------------------------------------------------------------------
PRESENTER FLOW:
1. Controller returns ['template' => 'X', 'data' => ['title' => 'Y', ...]]
2. App.php calls $presenter->render('X', ['title' => 'Y', ...])
3. Presenter.render() renders template content
4. Presenter.render() calls wrapWithDefaultLayout($content, 'Y')
5. wrapWithDefaultLayout() includes header (with title), menu, content, footer
6. Returns complete HTML page
🎉 Template wrapping is now centralized in Presenter!