We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37909
    • 153 Posts
    [[+total]]? It's a automatic placeholder display the number result (cf. getResources)
    • I see. So you have a custom chunk tpl for the Articles getResources output, and you use that placeholder in the chunk tpl. What do you want to do with that "total" value?

      If you want to display it, you can use an output modifier, the "div" modifier divides by two by default.
       
      [[+total:div]] 
      
        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
        • 37909
        • 153 Posts
        [[+total:div]] return 1,5
        However, I can't have a float number because I compare [[+total:div]] to [[+idx]]
        • I still don't understand what you are trying to do. If you have three items, of course dividing by two will return 1,5 You can check if +idx is greater than or less than +total:div
            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
            • 3749
            • 24,544 Posts
            Quote from: donshakespeare at Oct 17, 2015, 06:07 AM
            What is the type of input in the property set? Text or Intger?

            I don't think this matters (I could be wrong). I think you'll get a string no matter what.
              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
              • 3749
              • 24,544 Posts
              It's difficult to help because what you're describing is impossible. If returning $nb gives you three, returning (int)$nb would also give you three.

              This code, even with the space in front of the number, prints 3:

              $nb = " 3";
              $total = (int)$nb;
              echo $total;
              


              This code also prints 3:

              $nb = " 3.14";
              $total = (int)$nb;
              echo $total;


              Something else must be happening. Maybe the $scriptProperties value is not set every time, possibly because of a cache issue.
                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
                • 37909
                • 153 Posts
                With Articles, inside the main template (ex. ArticlesTpl), you just put [[*content]].
                In your content's resource, you just put [[+articles]] and you customize with a chunk (ex. tpl.ArticlesRow).
                This placeholder works like getResources except that in the chunk (inside tpl.ArticlesRow): [[+total]] doesn't work inside a snippet call. I think this is a bug.

                So, to “solve” this issue, I choose to don't use this specific system of Articles and I call directly getResources inside my main template (ArticlesTpl). I create a snippet because I need to provide some situations, specially when I have a research (by author, by date…).
                  • 3749
                  • 24,544 Posts
                  This could be a parsing order issue. If any of your tags has a ! at the front, that will delay processing of that tag and it may not be parsed at the time it's used.

                  It could also be a cache issue. If you look at the files in the cache, you may see your [[+total]] tag in there, unparsed. The placeholder won't be set because the snippet isn't actually run - it's results come from the cache.

                  You might try calling getResources and/or articles uncached:

                  [[!getResources]]
                  
                  [[!articles]]
                    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