We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: clareoconsulting at Jun 05, 2013, 03:41 PM
    Quote from: wshawn at Jun 05, 2013, 03:28 PM
    you want both pages to appear as canonical?

    I'm pretty sure that's not what he wanted - as I read it, he wanted the symlink resource to have a canonical link to the actual non-symlink resource URL that the symlink points to, not to its own URL.


    The Wayfinder?includeDocs is his easiest choice.
      Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

      Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
      • 36816
      • 109 Posts
      Quote from: wshawn at Jun 05, 2013, 03:53 PM
      The Wayfinder?includeDocs is his easiest choice.

      Agreed. Could well be easier to go that route.

      I can see, however, a use case where it may not be the easiest. {smile}. In the case where non-technical users are the ones doing ongoing maintenance, having them edit the Wayfinder call may not be the easiest/safest option. In that case, symlink or weblink are possibly better non-technical user options.

      As always, many ways to do things with MODX, eh? That's what makes it my go-to CMS.
      • Clareoconsulting's solution is perfect, I've tested it and it works fine!
        I'm on modxcloud and there are no problem about performance (site of about 100 pages).

        I didn't think about Wayfinder &includeDocs, anyway I think that this solution would redirect the user to the target resource, while my goal is to keep the user in the current section.

        Thanks again to everybody!
          TilliLab | MODX Ambassador
          website
        • Quote from: tillilab at Jun 05, 2013, 07:32 PM
          well, I think it works perfect! thanks smiley

          I wanted to do something like it, but using the key_class as control, something like:

          <!--?php
          $docid      = $modx--->resource->get('id');
          $resource   = $modx->getObject('modResource', $docid);
           
          if (($modx->resource->class_key)=='symlink')
          {
              $url = $modx->makeUrl($resource->get('content'), '', '', 'full');
              return '<link rel="canonical" href="' . $url . '">';
          }
          


          but $modx->resource->class_key always output "content".... so I think your solution will help me, thanks again!


          Almost right.. See my pull request on Github
          https://github.com/BobRay/Canonical/pull/1/files
            MODX Ambassador (NL) & Professional MODX developer
            Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
            MODX e-commerce solution SimpleCart
            • 7455
            • 2,204 Posts
            I know its kind of old treat, but this worked for us:

            [[*id:pdofield=`class_key`:is=`modSymLink`:then=`<link rel="canonical" href="[[~[[*id:pdofield=`content`]]]]"/>`]]


            it uses pdotools
              follow me on twitter: @dimmy01