We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16605
    • 16 Posts
    Hello there!
    does anybody know how to limit the size (characters to enter) of a template variable??

    plllleeeease help, I can’t find the answer
      • 3749
      • 24,544 Posts
      I believe the TV values for strings are limited to 65,535 characters in PHP5. Less if they contain multibyte characters.
        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
        • 30585
        • 833 Posts
        Quote from: lamarge at Mar 11, 2009, 11:47 AM

        Hello there!
        does anybody know how to limit the size (characters to enter) of a template variable??

        plllleeeease help, I can’t find the answer

        What do you mean by size?

        Are you referring to the content of a TV or its name. A richtext editor would allow much more room for the content than a simple text field would. Can you be a bit more specific and maybe tell us why need the info?
          A MODx Fanatic
          • 30585
          • 833 Posts
          Yeah, I don’t think it’s possible yet
            A MODx Fanatic
            • 16605
            • 16 Posts
            Hello!
            Thanks for your answers, what I am looking for is exactly that, I need to be able to limit the size of a tv, so that I can display it in a string length defined area.

            I came up with the solution of having a substring snippet, so I can always cut the output string if needed. I worked for a bit, I have realized that the snippet gets rid of quotation marks. I am using this solution to format the title of various news items, they need quotation marks, so again, I am in the same place... any suggestions guys? please :’(
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              You could use a plugin to add some javascript to do this; since it’s from the Manager and with relatively trusted users I don’t imagine the risk of someone hacking the page would be an issue.

              I’m presuming you’re using a text input type. If so, the input element for the TV will have an id attribute
              like id="tvMyTV". So you could have your javascript add the size and maxlenght attributes to that input element. Something like this: http://www.brighthub.com/internet/web-development/articles/9231.aspx
                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
                • 25663 MODX Staff
                • 12,272 Posts
                This definitely will require a custom plugin to be written, leveraging Javascript, or manually hacking the associated action page if it applies across the board. (Plugin is the best option)
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me