Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
4.0k views
in Plugins by
hello

i need to insert php code or html code

like stackoverflow site
Q2A version: 1.7 beta 2

3 Answers

0 votes
by
by
no i ask about http://ckeditor.com/addon/codesnippet
i am upload it to plugin foder in ckeditor after that what !!
by
You can use Express Editor ,
http://www.question2answer.org/qa/37420/free-codeeditor-for-q2a ,

The CodeSnippet and ACE Editor PLugins are included there . You can use it easily .
by
thanks i need it in ckeditor cuz i work from the begin with it and have youtube button
by
If you need to add youtube button , please check this post . Well detailed information provided
http://www.question2answer.org/qa/38943/tips-youtube-embed-video-iframe-with-ckeditor4-plugin?show=38943#q38943
by
> no i ask about http://ckeditor.com/addon/codesnippet
> i am upload it to plugin foder in ckeditor after that what !!

Ok....
I'll answer then in a separate Answer
0 votes
by
You could use this version of CkEditor for Q2A which have inbuilt Code Editor

http://www.question2answer.org/qa/37420/free-codeeditor-for-q2a

And syntax highlighters to highlight the code -

http://www.question2answer.org/qa/37512/code-highlighter-for-q2a

 

Hope this helps.
+2 votes
by
edited by

If you want to use the Code Snippet plugin with CKEditor4 you have to :

1) install and enable CKEditor4

2) download the CKEditor's Code Snippet plugin :

http://download.ckeditor.com/codesnippet/releases/codesnippet_4.4.6.zip

3) unzip it to your :

[q2a docroot]\qa-plugin\ckeditor4\plugins

folder

4) download the CKEditor's Widget plugin

http://download.ckeditor.com/widget/releases/widget_4.4.6.zip

5) unzip it to your 

[q2a docroot]\qa-plugin\ckeditor4\plugins

folder

6) download the CKEditor's Line Utilities plugin

http://download.ckeditor.com/lineutils/releases/lineutils_4.4.6.zip

7) unzip it to your 

[q2a docroot]\qa-plugin\ckeditor4\plugins

folder

8) download the CKEditor's Clipboard plugin

http://download.ckeditor.com/clipboard/releases/clipboard_4.4.6.zip

9) unzip it to your 

[q2a docroot]\qa-plugin\ckeditor4\plugins

folder

10) download the CKEditor's Dialog plugin

http://download.ckeditor.com/dialog/releases/dialog_4.4.6.zip

11) unzip it to your 

[q2a docroot]\qa-plugin\ckeditor4\plugins

folder

12) Go to :

Admin ---> CKEditor4 ---> options ----> "Toolbar buttons"

replace this line :

['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],

with this one :

['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','CodeSnippet'],

---> Save changes

13) Go to :

Admin ---> CKEditor4 ---> options ----> "Other configuration"

Replace this line :

entities:false

with these ones :

entities:false,
extraPlugins:'codesnippet,widget,lineutils,clipboard,dialog'

---> Save changes

14) Go to :

Admin --> Layout ---> Custom HTML in <head> section of every page

insert these 2 lines :

 
---> Save options
 
15) Go to :

Admin --> Layout ---> "Custom HTML at top of every page"

insert this line :

<script>hljs.initHighlightingOnLoad();</script>

---> Save options

It should work.

 

 

 

ps

The Code Snippet plugin declares as dependencies the following plugins : Widget, Dialog.

The Widget plugin declares as dependencies the following plugins : Line Utilities, Clipboard.

I've included all of them in the above installation procedure : I do not know if the "main" Code Snippet plugin really needs them or not.

by
Great explanation @MaxJ :) . (y)
by
Thanks Ami :-)
by
edited by
the button work fine and insert but after browse the question is it not show :(

http://oi59.tinypic.com/202w53.jpg
by
I'm sorry but I've not understood the snapshot you posted and what is not working....
Post an url if you want or/and give more details.
I do not see any issue on my instance...
by
i add php code just for echo

when i add it using the editor work fine

but after save the question it is show empty

like the screenshot
by
I've tested it on your website, and I do not see any issue opening a previously created question...
Have a look here :
http://www.question2answer.org/qa/?qa=blob&qa_blobid=14299378866519224269
by
post here the php code you've inserted
by
<?php

echo'test';

?>
by
could you zip and post somewhere (eg: dropbox) your
[q2a-docroot]\qa-plugin\ckeditor4
folder ?
(including the subdirs)
by
pls check also your web server's error log file for any error. I've tried to reproduce your error, even using rtl + arabic language, but without success. Everything's working in my environment (your issue seems related to the first "<", that is not correctly managed "somewhere"...)
by
and, in the :
Admin ---> CKEditor4 ---> options ----> "Other configuration"
use *only 1* extraPlugins directive. Now you have 2.
extraPlugins:'youtube'
extraPlugins:'codesnippet,widget,lineutils,clipboard,dialog'
Use (only) this one instead :
extraPlugins:'codesnippet,widget,lineutils,clipboard,dialog,youtube'
(so that your YouTube button is shown)
by
I think I've reproduced your issue (so I do not need anymore the zip file with your ckeditor4 files)
by
i think the problem from security that include in q&a
if i can use <script></scirpt> for example it may be xss attack !!
by
Mmm... I do not know the root cause yet.
I just can tell you that enabling the q2a "categories" I've been able to reproduce your issue.
Without the categories, everything worked.
by
(so, imho, it doesn't seem a "security" issue)
by
more investigation is needed....
...