We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26435
    • 1,193 Posts
    This is an auto-generated support/comment thread for tagLinks.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Gets the tags for the current page (if any are set) from a tv and creates links out of them.
    Lots of fun parameters. See this wiki page for explanations and examples.

    -sD-
    Dr. Scotty Delicious, Scientist.
      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
      All of the above... in no specific order.


      I send pointless little messages
      • 30481
      • 33 Posts
      Good job !

      I was thinking that it would be cool to have this feature... you made it !

      All seems OK, but i think i found a little bug with the $separator.
      In the two case (format = `a` or not), you do the following when you are closing the anchor tag :
      .$value.'</a>, '.$separator.$nl;
      or
      ..$value.'</a>, '.$separator.'</li>'.$nl;


      I think that the ", " is too much after the anchor closing. It is the job of the $separator variable to do that.
      Other thing, you always put the separator... also for the last item. I don’t thing it it that we want.
      In my case, if i have only one tag (it’s a category), it shows: "my category,".... Year, i think we should not put the separator for the last entry....
      You should replace the foreach by another buckle to do the job on all entry but not the last one... the last one is to be build outside the buckle.

      All other thing are OK and great !!!
      Thanks !

      Totor.
      www.totor.fr

        -------------------------------
        www.fabienletort.com
        • 26435
        • 1,193 Posts
        HAHA!!!
        you are right grin

        I put those commas in there to test the output before I decided to make the separator a variable. I just forgot to take them out. I have updated this snippet in the repository.

        -sD-
        Dr. Scotty Delicious, Scientist.
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages
          • 30481
          • 33 Posts
          yep, ok, very quick !

          But the separator is always put for the last item in your new version ?

          Totor
          www.totor.fr
            -------------------------------
            www.fabienletort.com
            • 26435
            • 1,193 Posts
            It was for the old version too.
            I haven’t quite figured out how to specify the last item in a foreach loop.
            This is one of the things I want to do though.

            -sD-
            Dr. Scotty Delicious, Scientist.
              Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
              All of the above... in no specific order.


              I send pointless little messages
              • 29883
              • 15 Posts
              That looks like a cool thing. I started with MODx just 2 days ago - so this snippet came out just the right time smiley

              I only encountered one problem. On my test site I have the tags A, B, C..., seperated with pipes. When I use

              [!tagLinks? &id=`[*id*]` &tv=`kategorie` &separator=`|` &label=`Kategorie(n): ` !]

              the output will be:

              <a href="foo/a|e|g">

              What am I doing wrong?

              Many thanks for help.
                • 6726
                • 7,075 Posts
                Nice one scotty smiley

                I’ll sure give this one a test run !
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l&#39;outil id
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Quote from: Dr. at Dec 12, 2006, 12:51 PM

                  It was for the old version too.
                  I haven’t quite figured out how to specify the last item in a foreach loop.
                  This is one of the things I want to do though.

                  -sD-
                  Dr. Scotty Delicious, Scientist.
                  So don’t use a foreach loop. Use a for() loop instead.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    That got my curiosity stirred up, so I did some investigating. After a foreach loop, the value of the $key=>$value variables is still available as the last item in the original array.

                    $testarray = array('first' => 1, 'second' => 2, 'third' => 3, 'fourth' => 4);
                    foreach($testarray as $key => $value) {
                      echo $key . ' = ' . $value . '<br />';
                    }
                    echo "---------------------<br />And after: " . $key ." = " . $value;
                    

                    first = 1
                    second = 2
                    third = 3
                    fourth = 4
                    ---------------------
                    And after: fourth = 4
                    Learn something new every day!
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 18397
                      • 3,250 Posts
                      Please note that this feature is in Ditto 1.1 Beta 1 or later so if you are using that version please use the [+tags+] placeholder for optimum performance.