Quote from: tillilab at Jun 05, 2013, 01:49 PMI tried this extra
Ah, heck, I'm sorry. I was relying on my memory when I replied, and that wasn't a good idea. I just went into the site where I used it and my memory came back when I saw how I'd handled it.
Bob's snippet didn't work in that use case, so I wrote my own. I'll include it here for your review or use as you see fit. There may be other ways to do this, but this one has worked for me.
Call it whatever you want, and just put a call to it in your HTML head section - no parameters needed. As written, on symlinks, it'll output a canonical link. On "regular" pages (the canonical page in my use case), it has no output.
<?php
$docid = $modx->resource->get('id');
$resource = $modx->getObject('modResource', $docid);
if (is_numeric($resource->get('content')))
{
$url = $modx->makeUrl($resource->get('content'), '', '', 'full');
return '<link rel="canonical" href="' . $url . '" />';
}