Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.7k views
in Plugins by
Can we prepopulate the ckEditor with some default text?

Something like:

 

Hi

[ your question/ comment]

regards

2 Answers

0 votes
by

 you could use jquery client-side

+1 vote
by

I will deal in layer.

Example code: (Add override function below in your theme.php)

function main_parts($content) {
  if($this->template == 'ask') {
    if(isset($content['form']['fields']['content']['value'])) {
      $value = &$content['form']['fields']['content']['value'];
      if(empty($value)) {
        if(qa_opt('editor_for_qs') == '')
          $value = 'Hi'.PHP_EOL.PHP_EOL.'[your question]';
        else
          $value = '<p>Hi</p><p>[your question]</p>';
      }
    }
  } else if($this->template == 'question') {
    if(isset($content['a_form']['fields']['content']['value'])) {
      $value = &$content['a_form']['fields']['content']['value'];
      if(empty($value))
        if(qa_opt('editor_for_as') == '')
          $value = 'Hi'.PHP_EOL.PHP_EOL.'[your answer]';
        else
          $value = '<p>Hi</p><p>[your answer]</p>';
    }
    if(isset($content['q_view']['c_form']['fields']['content']['value'])) {
      $value = &$content['q_view']['c_form']['fields']['content']['value'];
      if(empty($value))
        if(qa_opt('editor_for_cs') == '')
          $value = '[your comment]';
        else
          $value = '<p>[your comment]</p>';
    }
    if(isset($content['a_list']['as'])) {
      $as = &$content['a_list']['as'];
      if(is_array($as)) {
        foreach($as as $key=>$a) {
          if(isset($as[$key]['c_form']['fields']['content']['value'])) {
            $value = &$as[$key]['c_form']['fields']['content']['value'];
            if(empty($value))
              if(qa_opt('editor_for_cs') == '')
                $value = '[your comment]';
              else
                $value = '<p>[your comment]</p>';
          }
        }
      }
    }
  }
  qa_html_theme_base::main_parts($content);
}
by
Thank you Sama55 you are the master of php in here. Its just a bit slow. Any faster solutions ( in terms of loading time)
...