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