Hi all,
I want to create a google canonical tag on symlink pages to the original page. I have made a tv for this value (named: seoCanonical) and now I want to create the value when the page is loading. So I have made a plugin and linked it to the OnWegPagePrerender event. The plugin is working correctly but the value isn’t avalable on the first time viewing the page. Could anyone help me out?
This is my ’AutoCanonical’ plugin
$c = $modx->newQuery('modResource');
$c->where(array(
'id' => $modx->resource->get('id'),
'class_key' => 'modSymLink'
));
$orgResource = $modx->getObject('modResource', $c);
if(!empty($orgResource) && is_object($orgResource)) {
$symlinkID = $orgResource->get('content');
$symlinkURL = $modx->makeUrl($symlinkID, '', '', 'full');
$tv = $modx->getObject('modTemplateVar', 4); // canonical tv
$tv->setValue($modx->resource->get('id'), $symlinkURL);
$tv->save();
}
Thanks in advance
Regards, Bert