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

    How to limit comments length with Jot?
    It seems there is no limit by default, and i don’t find the right parameter to do that.

    Thanks!
      • 33992 ☆ A M B ☆
      • 455 Posts
      Hello,

      I think the easiest way is using HTML and Javascript tricks like this:
      How to limit the number of characters entered in a textarea in an HTML form and other notes on textarea elements
        God loves me. 【ツ】


        MODX.ir (Persian Support)

        Boplo.ir/modx/ (Persian)
        • 6855
        • 11 Posts
        Thanks AHHP wink

        I don’t like doing that with js, because if js is disabled, the check is disabled too. Could be a security problem (if flooded with very long comments).
        But it’s better than no test at all.
        So I add to the wish-list for next versions of Jot a parameter to refuse a comment if too long.
        This is not a complaint, just a wish wink
        I love modx and all the stuff around, i want to thank all the modx staff and contributors for this amazing and powerful CMS.
          • 6855
          • 11 Posts
          In the case someone is interested, here is a small hack to add max length to jot:

          In the Jot snippet:
          $Jot->Set("maxlength", $maxlength);

          In jot.class.inc.php function Run()
          $this->config["maxlength"] = !is_null($this->Get("maxlength")) ? intval($this->Get("maxlength")) : 5000;

          In jot.class.inc.php function processForm
          if ($saveComment && $this->config["maxlength"] > 0) {
                                  if (strlen($_POST["content"]) > $this->config["maxlength"]) {
                                          $this->form['error'] = 6;
                                          $saveComment = 0;
                                          return;
                                  };
                          };

          In templates/chunk.form.inc.php, into [+form.error:select=
          &6=Comment too long.


          Then you can call jot with &maxlength=`123456` to refuse comments longer than 123456 chars. (default= 5000 chars, call with `0` to disable limit).