diff --git a/migrations/Version20230205104809.php b/migrations/Version20230205104809.php new file mode 100644 index 0000000000000000000000000000000000000000..b06f4052809b62e72f892452818a7605e61414a4 --- /dev/null +++ b/migrations/Version20230205104809.php @@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20230205104809 extends AbstractMigration +{ + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + // this up() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE page ADD template VARCHAR(255) NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE page DROP template'); + } +} diff --git a/src/Controller/PageController.php b/src/Controller/PageController.php index 86b70e7aa096c2f804f2627be0b0d7e5e3f96c9f..76ea5da43dad5f2510fa1dfc06bbf1f7ea31cc8e 100644 --- a/src/Controller/PageController.php +++ b/src/Controller/PageController.php @@ -40,7 +40,7 @@ class PageController extends AbstractController $page = $pageRepository->getPageFromURL($request->getPathInfo()); if ($page) { $page = $placeholderService->replacePlaceholderInPage($page); - return $this->render('pages/page.html.twig', [ + return $this->render('template/' . $page->getTemplate() . '.html.twig', [ 'page' => $page, 'captcha' => $captchaService->getInlineCaptcha(), 'name' => '', diff --git a/src/Entity/Page.php b/src/Entity/Page.php index 8c322b8177b0adfab23300472d8f8c5795de4528..0c20b604ffc5e28293b4c935ea869225f1806195 100644 --- a/src/Entity/Page.php +++ b/src/Entity/Page.php @@ -40,6 +40,9 @@ class Page #[ORM\Column] private ?bool $hasPlaceholder = false; + #[ORM\Column(length: 255)] + private ?string $template = 'page'; + public function __construct() { $this->createDate = new \DateTimeImmutable(); @@ -183,4 +186,16 @@ class Page return $this; } + + public function getTemplate(): ?string + { + return $this->template; + } + + public function setTemplate(string $template): self + { + $this->template = $template; + + return $this; + } } diff --git a/templates/pages/page.html.twig b/templates/template/page.html.twig similarity index 98% rename from templates/pages/page.html.twig rename to templates/template/page.html.twig index 9f65ba9f98f72cf686fb8b9a68a77b8f2ea27eb5..ce96fc1239a4452ebeea540c46975951a9ebb58b 100644 --- a/templates/pages/page.html.twig +++ b/templates/template/page.html.twig @@ -1,4 +1,4 @@ -{% extends 'base.html.twig' %} +{% extends '../base.html.twig' %} {% block title %}{{ page.title }}{% endblock %} {% block content %} {% apply markdown_to_html %} diff --git a/templates/template/raw.html.twig b/templates/template/raw.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..3b74402575a17b260d28cfad338b52cee4e7fb18 --- /dev/null +++ b/templates/template/raw.html.twig @@ -0,0 +1 @@ +{{ page.content }} \ No newline at end of file