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
    Very nice!!!
    thank you for posting this revision

    -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
      • 18397
      • 3,250 Posts
      I’ve attached a version of tagLinks to this post that trims the tags in the method Ditto does as well as cleanly fixing the "extra comma" issue.
        • 30884
        • 142 Posts
        Very nice, just what I’ve been looking for! Can I ask a quick question?

        I’m using the NewsPublisher snippet to post articles inline and I’ve managed to cobble together a reasonably solid way of posting articles, their associated media etc.
        (http://www.modxcms.com/blog-publish.html) as laid out here.

        What I’m needing to do is to have a way to get that ’tags’ TV present and selectable in-line alongside the NewsPublisher snippet.

        I’m able to go into the backend and set the TV settings accordingly but this is something I’d like to do when I’m posting articles as a content-editor logged on in the webpage itself and keep out of the backend as much as possible. (well keep the eventual end users out of the ModX backend as much as possible I should say)

        Cheers
        TXRX
          p i x e l p u s h e r e x t r o d i n a i r e
          A x i s A n i m a t i o n . c o m
          • 2328
          • 39 Posts
          I think I may have found a bug with v1.0.3 in the repository - when using it for a page (rather than within Ditto), it fails to pull back the contents of the TV (it just gives the value "array").

          As far as I can make out, the fault lies at the point where it checks for the contents of the $value parameter - the ’else’ call to $modx->getTemplateVarOutput seems to assume the function will return a string, whereas it actually returns an array of strings.

          It’s easily fixed - simply wrap the function call in an implode(’,’,...) statement, like so:

          $get_tags = isset($value) ? $value : implode($delimiter,$modx->getTemplateVarOutput($idname=array($tv), $page_id, $published="1"));
          


          If anyone can confirm this, it might be worth adding to the next release smiley
            • 26435
            • 1,193 Posts
            Good work Astronut.
            Does it still work with Ditto with this modification?
            Not that it really matters as Ditto 2 has a much better method for handling tags now (I wrote this snippet to address a shortcoming of Ditto 1).

            Anyway, if it does work with Ditto I will update the resource in the repository with your code.

            -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
              • 2328
              • 39 Posts
              Quote from: Dr. at Aug 04, 2007, 08:30 AM

              Does it still work with Ditto with this modification?

              Hi Doc,

              To be honest, I couldn’t tell you smiley I’m actually using the tagging extension in Ditto 2 for my summary pages, with tagLinks for the actual post pages.

              If I understand the relevant code, it shouldn’t make any difference, because the Ditto usage pulls the tags directly from the ’value’ parameter (is that correct?). That should bypass this change, which only applies when $value is not set.

              I realised where the problem was when I saw that $value would always be a $delimiter-separated string, while gettemplatevaroutput returns an array. The implode simply creates a $delimiter-separated string from the array, which is subsequently re-exploded by the following code. You could probably make things slightly more efficient by exploding $value as soon as it’s checked and not exploding it later, but that was two changes in code that I’d already hacked considerably grin

              Incidentally, I’ve got a whole load of other modifications to this script, mostly to allow for a single category page (specified by id), using Ditto’s tagging extension to customise it, rather than create separate pages for each category (it seemed a lot more flexible). I can post it if you like.
                • 26435
                • 1,193 Posts
                Wow, very cool that this snippet is still useful in a totally different way than what I was working for back then.
                If you want to post the code you have so far along with any additional specific instructions you think would be helpful, I would post it in the repository (sorry, I can’t figure out how to add your username so that you could post new versions too. I don’t know if it is possible).

                Make sure you add your credits to the head comments if you haven’t already.

                Should it be posted as version 2?

                -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
                  • 7792
                  • 2 Posts
                  I can confirm that Astronut’s modification fixes the problem that I’ve been getting with tagLinks 1.0.3.

                  I’ve also had to hack it a bit for Ditto 2.0.2. The URL links it was generating would not generate the proper call to display the pages.

                  I’ve come upon a problem, though. Hope you guys can help. Here’s the description:

                  The tv I’m using has multiple values, created using a multi-select checkbox. The original values are separated by the "||" delimiter. I’ve checked the database and I can also see that the tv values are separated by the same delimiter.

                  However, when I make the call

                  [[tagLinks? &tv=`tags` &delimiter=`|` &separator=`, `]]

                  the resulting tags come out concatenated. I can’t seem to separate them! (For example, if the tag value was "FOSS||Telecom", tagLinks interprets it as "FOSSTelecom"

                  Any suggestions?
                    • 18397
                    • 3,250 Posts
                    The delimiter should be || (note it is two | characters)
                      • 5091
                      • 332 Posts
                      I couldn’t get the tag works nicely with Ditto call , so decided to revisit and upgrade the tagLinks. I downloaded the 1.0.3 version, in the snippet, I still see the * @version 1.0.2. Can you please confirm if the 1.0.3 download is indeed the latest.

                      Thank!