We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33077
    • 4 Posts
    Hello, have discovered Modx - an excellent CMS!

    I am using the rte, [*blogContent*] tv, in a form, but can’t figure out how to set the initial content for the editor. Assume I have to program an event or something like that???

    Thanks for help.
      • 33077
      • 4 Posts
      Well, couldn’t figure out how to initialize content using the blogContent tv, so made a chunk with the TinyMCE code using the editor_selector option which allows for easier selection of std textarea or rte input.
      Chunk ’enableRte’
      <script language="javascript" type="text/javascript" src="[(base_url)]assets/plugins/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
      <script language="javascript" type="text/javascript">
      tinyMCE.init({	
              mode : "textareas",
              editor_selector : "rte"
      });
      </script>

      Then can use in a form snippet, example to enable using the class="rte" parameter’
      $content = isset($_POST['content']) ? $_POST['content'] : 'Initial info';
      $modx->setPlaceholder('content', mysql_real_escape_string($content));
      $output = '{{enableRte}}
        <form method="post" action="[~[*id*]~]">
         Content:</br>
         <textarea name="content" class="rte" rows="15" cols="50">[+content+]</textarea>
         <input type="submit">
        </form>';
      return $output;

      This seems a simpler approach where it’s easier to choose a simple textarea (no class="rte") or to use an rte as shown above.
        • 4018
        • 1,131 Posts
        I assume by initial content you mean default content, right? If so, the default content can be set in the TV itself via the Default Value field. Hope this helps! smiley
          Jeff Whitfield

          "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
          • 33077
          • 4 Posts
          Right, I mean the default content. The problem w/seting in the TV is that I would need a TV for each rte item with each having it’s own default content, right? Also, can I set the default content programaitcally so that it retrieves initial content from a database? I’m making an edit document form w/an rte input for content that needs to have initial content from a document with varying id depending what document is being edited.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Maybe the default content could be something like @DOCUMENT [*id*]
              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
              • 33077
              • 4 Posts
              Well the document id is passed to the form dynamically (via a GET or POST), how do I get the id to the TV default input.....I don’t see how to make this work via the blogContent TV...maybe I’m missing how to link this together?
                • 4018
                • 1,131 Posts
                Where is the initial content gonna be stored? In another document? Or in a chunk or something like that? You can easily create an @ binding that will grab the content from the database.
                  Jeff Whitfield

                  "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."