Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Adding an Editor to a Page?

+3 votes
517 views
asked Jul 19, 2013 in Q2A Core by Bruno Vandekerkhove
I made a new page which would be an 'article submission'. The articles would be written like you write a question, but they would be stored differently. The first challenge is to get the editor to show on my page. How would I do so?

I tried copying some code from qa-page-ask.php but it doesn't display the form right.
Q2A version: 1.6.1
commented Jul 19, 2013 by monk333
Dont know what exactly is Your approach, but why not use the same editor and add a checkbox question or article. Or use two different buttons which send over a hidden marker.

Please read the following two questions as, well may be they do help:

http://www.question2answer.org/qa/15167/is-it-possible-to-add-more-types-to-the-post

http://www.question2answer.org/qa/10389/i-can-not-change-max-text-lenght-please-help
commented Jul 19, 2013 by Bruno Vandekerkhove
Well I just need to display the default editor on a new page. You solutions would require hard-coding in the qa-page-ask.php file, I think!

1 Answer

0 votes
answered Jul 20, 2013 by Bruno Vandekerkhove

Currently this is the code I use for the content of my custom page : 

 

$qa_content=qa_content_prepare();
 
$editorname=isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs');
$editor=qa_load_editor(@$in['content'], @$in['format'], $editorname);
 
$field=qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false);
$field['label']=qa_lang_html('question/q_content_label');
$field['error']=qa_html(@$errors['content']);
 
$custom=qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : '';
 
$qa_content['form']=array(
'tags' => 'name="ask" method="post" action="'.qa_self_html().'"',
 
'style' => 'tall',
 
'fields' => array(
'custom' => array(
'type' => 'custom',
'note' => $custom,
),
 
'similar' => array(
'type' => 'custom',
'html' => '<span id="similar"></span>',
),
 
'content' => $field,
),
 
'buttons' => array(
'ask' => array(
'tags' => 'onclick="qa_show_waiting_after(this, false); '.
(method_exists($editor, 'update_script') ? $editor->update_script('content') : '').'"',
'label' => qa_lang_html('question/ask_button'),
),
),
 
'hidden' => array(
'editor' => qa_html($editorname),
'code' => qa_get_form_security_code('ask'),
'doask' => '1',
),
);
 
return $qa_content;
 
But it won't display the editor right - the stylesheets or scripts are apparently not loaded...
...