Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

SEO Keywords not save #93

Open
Nik-ADA opened this issue May 16, 2019 · 1 comment
Open

SEO Keywords not save #93

Nik-ADA opened this issue May 16, 2019 · 1 comment

Comments

@Nik-ADA
Copy link

Nik-ADA commented May 16, 2019

I try create plugin in MODx for event OnDocFormSave.

part of my code

$seoKeywords = $modx->getObject('seoKeywords', array('resource' => $resource->get('id')));
if (!$seoKeywords && isset($resource)) {
	$seoKeywords = $modx->newObject('seoKeywords', array('resource' => $resource->get('id')));
}

if ($seoKeywords) {
	$keywords = implode(",", $videoTags);
	if (isset($keywords)) {
		$seoKeywords->set('keywords', trim($keywords, ','));
	}
	$seoKeywords->save();
}

tried to add $resource->save(); but still the keywords are not saved.
What could be the problem

@Nik-ADA
Copy link
Author

Nik-ADA commented May 16, 2019

I fix this in your plugin:

if (isset($_POST['keywords'])){
$seoKeywords->set('keywords', trim($_POST['keywords'], ','));
} else {
$seoKeywords->set('keywords', '');
}

$keywords = isset($_POST['keywords']) ? $_POST['keywords'] : $seoKeywords->get('keywords');
$seoKeywords->set('keywords', $keywords);
/*if (isset($_POST['keywords'])){
	$seoKeywords->set('keywords', trim($_POST['keywords'], ','));
} else {
	$seoKeywords->set('keywords', '');
}*/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant