Answer the question
In order to leave comments, you need to log in
Why might the Canonical plugin not work?
Installed the Canonical add-on on ModX Revo ( https://docs.modx.com/extras/revo/canonical), inside the ... section added a call to the snippet. The result of the work is an empty line in the html code. What could be the problem?
Answer the question
In order to leave comments, you need to log in
The condition in the snippet fails - this page doesn't need link=canonical.
$docId = $modx->resource->get('id');
$query = $modx->newQuery("modSymLink");
$query->select(array(
'id',
'class_key',
'content',
));
$query->where(array(
'id' => $docId,
'class_key' => 'modSymLink'
));
if ($query->prepare() && $query->stmt->execute()) {
$results = $query->stmt->fetchAll(PDO::FETCH_ASSOC);
}
if (!empty($results)) {
$id = (integer) $results[0]['content'];
$url = $modx->makeUrl($id, '', '', 'full');
return '<link rel="canonical" href="' . $url . '" />';
}
return '';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question