RenderLayout metodu oz MVC framworkunuz ucun
Gelin indi renderLayout metodunu yaradaq.
Bu metod layout faylini goturerek icinde $title
ve $content variable-larinin qiymetlerini
yerlesdirecek (o, metodun parametri kimi oturulecek
ve renderView metodunun ishlenmesinin
neticesi olacaq):
<?php
private function renderLayout(Page $page, $content) {
$layoutPath = $_SERVER['DOCUMENT_ROOT'] . "/project/layouts/{$page->layout}.php";
if (file_exists($layoutPath)) {
ob_start();
$title = $page->title;
include $layoutPath; // burada $title ve $content variable-lari elcatandi olacaq
return ob_get_clean();
}
}
?>