We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37747
    • 50 Posts
    MODX Revolution 2.2.8-pl (traditional)
    MySQL: 5.5.37-0ubuntu0.12.04.1
    PHP: 5.4.28-1~dotdeb.0

    I'm doing a code cleanup based on an SEO audit of the site and one of the issues that was found is that we have different URLs for identical tag landing pages eg.
    mydomain.com/tag-results?tag=foo
    and
    mydomain.com/tag-results?tag=foo&key=tags

    The problem comes from the toLinks snippet appending the parameter onto the end of the URL, here is how I am using tagLister and toLinks:

    tagLister
    <!-- Snippet call -->
    [[tagLister? &tv=`tags` &target=`10` &limit=`99` &tpl=`tag-list` &parents=`2`]]
    
    <!-- Output -->
    <li class="[[+cls]]">
      <a href="[[~[[+target]]? &[[+tagVar]]=`[[+tag]]`]]">[[+tag]]</a>
    </li>
    


    toLinks
    Tags: [[tolinks? &items=`[[+tv.tags]]` &key=`tag` &target=`10`]]
    


    I also tried removing the
    &key=`tag`
    from the toLinks call altogether which surprisingly made absolutely no difference and the snippet carried on working as before outputting the same URLs so not sure why it's included in the documentation here: http://rtfm.modx.com/extras/revo/taglister/taglister.tolinks

    Any help would be much appreciated.
      • 37747
      • 50 Posts
      Bump. Nobody?
        • 3749
        • 24,544 Posts
        You might try this:

        Tags: [[tolinks? &items=`[[+tv.tags]]` &tagKeyVar=`` &tagKey==`` &target=`10`]]


        I think that will remove the second argument from the query string.


          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 37747
          • 50 Posts
          Quote from: BobRay at Jul 09, 2014, 08:55 PM
          You might try this:

          Tags: [[tolinks? &items=`[[+tv.tags]]` &tagKeyVar=`` &tagKey==`` &target=`10`]]


          I think that will remove the second argument from the query string.



          Hi BobRay,
          Thanks for getting back to me. That almost does it but you're left with a URL that looks like this now:

          mydomain.com/tag-results?tag=foo&=

            • 3749
            • 24,544 Posts
            I was afraid of that. I think the only way out is to either hack the toLinks code or create your own snippet, custom output modifier, or plugin to fix it. I think this might do it:


            Tags: [[RemoveCrap? &text=`[[tolinks? &items=`[[+tv.tags]]` &target=`10`]]`]]



            /* RemoveCrap snippet */
            return str_replace('&key=tags', '', $scriptProperties['text']);
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting