From aaeb506e55f4b4e524584d9452cda08ae5e7bfe4 Mon Sep 17 00:00:00 2001 From: Elias Luhr Date: Wed, 8 Jan 2020 10:40:46 +0100 Subject: [PATCH] check if meta tags not empty before setting --- controllers/DefaultController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php index b56b560..be59fc2 100644 --- a/controllers/DefaultController.php +++ b/controllers/DefaultController.php @@ -168,8 +168,13 @@ public function actionPage($pageId) $this->view->title = $page->page_title ?: $page->name; // Register default SEO meta tags - $this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords],'meta-keywords'); - $this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description], 'meta-description'); + if (!empty($page->default_meta_keywords)) { + $this->view->registerMetaTag(['name' => 'keywords', 'content' => $page->default_meta_keywords],'meta-keywords'); + } + + if (!empty($page->default_meta_description)) { + $this->view->registerMetaTag(['name' => 'description', 'content' => $page->default_meta_description], 'meta-description'); + } // Render view return $this->render($page->view, ['page' => $page]);