We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10357
    • 573 Posts
    Hi,

    is there anyway to change the output of count-comments based on the post count. So for example if the comments = 0 the text reads "add a comment".

    cheers,
    G
      • 4195
      • 398 Posts
      you can achieve this with PHx. If i have the time i will post the tag example.
        Armand Pondman
        MODx Coding Team
        :: Jot :: PHx
        • 10357
        • 573 Posts
        thanks that would be great grin
          • 4195
          • 398 Posts
          You have to have PHx active as a plugin (PHx 2.0.1 from the repository)

          if you use the snippet call that returns the comment count use this:

          [+phx:if=`[!Jot?&docid=`[+id+]`&action=`count-comments`!]`:is=`0`:then=`add a comment`:else=`[!Jot?&docid=`[+id+]`&action=`count-comments`!]`+]
          


          remember that [+id+] can be any variable that returns the document id for the requested comment count

          or if you use placeholder=`1` in your jot call and it’s on the same page as the comment count.

          [+jot.nav.total:is=`0`:then=`add a comment`:else=`[+jot.nav.total+]`+]
          
            Armand Pondman
            MODx Coding Team
            :: Jot :: PHx
            • 10357
            • 573 Posts
            thanks, works a treat grin

            this is my final code with the links to the comments:

            [+phx:if=`[!Jot?&docid=`[+id+]`&action=`count-comments`!]`:is=`0`:then=`<a class="count" href="[~[+id+]~]#commentsAnchor">add a comment</a>`:else=`<a class="count" href="[~[+id+]~]#commentsAnchor">Comments ([!Jot?&docid=`[+id+]`&action=`count-comments`!])</a>`+]


            is it possible to add another condition to the statement? e.g if=`[!Jot?&docid=`[+id+]`&action=`count-comments`!]`:is=`1`:then=.. i could not work out the syntax.

              • 30481
              • 33 Posts
              It is really working ?

              The case 0 is not working for me...
              The call to Jot snippet really return a number ? not a string ?

              EDIT: ok ! I need to make Jot call with [[ and not [!
                -------------------------------
                www.fabienletort.com