From 7da12f3d4bc87663b1e9f540794dc56d039d2629 Mon Sep 17 00:00:00 2001 From: Anubarak Date: Tue, 2 Jul 2024 09:54:56 +0200 Subject: [PATCH] change property exists check in order to set the correct typeId. property_exists will return false for typeId param because it's a function now. check if seoField exists in the fieldLayout --- src/controllers/SeoController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/controllers/SeoController.php b/src/controllers/SeoController.php index 9d18d2a..df4f6bc 100644 --- a/src/controllers/SeoController.php +++ b/src/controllers/SeoController.php @@ -66,7 +66,7 @@ public function actionRenderData () $body = $craft->request->getBodyParams(); foreach ($body as $prop => $value) { - if (!property_exists($element, $prop)) + if (!$element->canSetProperty($prop)) continue; if (in_array($prop, ['postDate', 'expiryDate'])) { @@ -83,7 +83,10 @@ public function actionRenderData () $craft->request->getParam('fieldsLocation', 'fields') ); - return $this->asJson($element->$seoHandle->titleAsTokens); + $field = $element->getFieldLayout()?->getFieldByHandle($seoHandle); + $value = $field? $element->getFieldValue($seoHandle) : null; + + return $this->asJson($value? $value->titleAsTokens : []); } } \ No newline at end of file