diff --git a/kernel/CgView.php b/kernel/CgView.php index 792c540..3057293 100644 --- a/kernel/CgView.php +++ b/kernel/CgView.php @@ -10,6 +10,8 @@ class CgView public array $varToLayout = []; public bool|string $layout = false; + protected array $metaArr = []; + public function __construct() { @@ -34,14 +36,37 @@ class CgView $this->varToLayout[$key] = $value; } - private function createContent(string $view, array $data = []): false|string + public function setTitle(string $title): void + { + $this->addVarToLayout('title', $title); + } + + public function setMeta(array $meta): void + { + foreach ($meta as $key => $value){ + $this->metaArr[$key] = $value; + } + } + + public function getMeta(): string + { + $meta = ""; + foreach ($this->metaArr as $key => $value){ + $meta .= ""; + } + + return $meta; + } + + private function createContent(string $viewFile, array $data = []): false|string { ob_start(); + $view = $this; foreach ($data as $key => $datum) { ${"$key"} = $datum; } - include($this->viewPath . $view); + include($this->viewPath . $viewFile); $content = ob_get_contents(); ob_end_clean(); diff --git a/kernel/admin_themes/default/layout/main.php b/kernel/admin_themes/default/layout/main.php index 5864fb1..db00106 100644 --- a/kernel/admin_themes/default/layout/main.php +++ b/kernel/admin_themes/default/layout/main.php @@ -2,15 +2,18 @@ /** * @var $content * @var string $resources + * @var string $title + * @var \kernel\CgView $view */ \Josantonius\Session\Facades\Session::start(); ?>
-