cg view title, meta
This commit is contained in:
parent
f7253bafe9
commit
9c77403a71
@ -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 .= "<meta name='$key' content='$value'>";
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -2,15 +2,18 @@
|
||||
/**
|
||||
* @var $content
|
||||
* @var string $resources
|
||||
* @var string $title
|
||||
* @var \kernel\CgView $view
|
||||
*/
|
||||
\Josantonius\Session\Facades\Session::start();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Sidebar 01</title>
|
||||
<title><?= $title ?></title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<?= $view->getMeta() ?>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $contents
|
||||
* @var int $page_number
|
||||
* @var \kernel\CgView $view
|
||||
*/
|
||||
|
||||
use kernel\modules\post\models\Post;
|
||||
@ -21,6 +22,11 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
|
||||
'baseUrl' => "/admin/post"
|
||||
]));
|
||||
|
||||
$view->setTitle("Список постов");
|
||||
$view->setMeta([
|
||||
'description' => 'Список постов системы'
|
||||
]);
|
||||
|
||||
$entityRelation = new \kernel\EntityRelation();
|
||||
$additionals = $entityRelation->getEntityRelationsBySlug("post");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user