Yii tinymce implements syntax highlighting

Source: Internet
Author: User

Introduction: This is a detailed page for yii tinymce syntax highlighting. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 332632 'rolling = 'no'>

First, download yii tinymce.
Extension, put it in your extensions directory,

Step 2 downloadSyntaxhighlighter, decompress the package and put the necessary files in your JS and CSS directories,

Shcore. JS, shcore.css, shthemedefault.css

These three are necessary files, plus the language you need to highlight. If it is Php, add shbrushphp. JS and Java are added to shbrushjava. JS. For more information, see the official documentation.

You can register directly in your controller action, for example:

 
$clientScript = Yii::app() -> clientScript;$clientScript -> registerScriptFile("/js/syntaxhighlighter/shCore.js");$clientScript -> registerScriptFile("/js/syntaxhighlighter/shBrushJava.js");$clientScript -> registerScriptFile("/js/syntaxhighlighter/shBrushJScript.js");$clientScript -> registerScriptFile("/js/syntaxhighlighter/shBrushPhp.js");$clientScript -> registerCssFile("/css/syntaxhighlighter/shCore.css");$clientScript -> registerCssFile("/css/syntaxhighlighter/shThemeDefault.css"); 

Step 3 downloadInstall syntaxhighlighter of tinymce

Address: http://github.com/RichGuk/syntaxhl

Download and decompress the package.Protected \ extensions \ tinymce \ assets \ tiny_mce \ plugins
Directory

Add the following parameters to your form page and display them in bold.

'plugins'=>'syntaxhl', 'theme_advanced_buttons1' => 'syntaxhl',
 
<?php $this->widget('application.extensions.tinymce.ETinyMce',            array('id'=>'postBody','name'=>'body','useSwitch'=>false, 'editorTemplate'=>'full','language' => 'zh',                    'model' => $postText,'attribute'=>'body',                         'options' => array('theme' => 'advanced','skin' => 'o2k7','skin_variant'=>'silver',                    'theme_advanced_resize_horizontal'=>false,'plugins'=>'syntaxhl','remove_linebreaks'=>false,                    'extended_valid_elements'=>'textarea[cols|rows|disabled|name|readonly|class]' ,                    'theme_advanced_buttons1' => 'preview,bold,italic,underline,fontselect,fontsizeselect,link,justifyleft,justifycenter,justifyright,table,image,|,bullist,numlist,|,undo,redo,|,code,syntaxhl,fullscreen',                        'theme_advanced_buttons2' => '',                        'theme_advanced_buttons3' => '',                ))); ?> 

Tinymce will add a new button at the end.

The Code highlighting function is completed in a few steps. Check this article. Of course, you can also expand the code copying function on your own.

From: It News Network
| Original address: http://www.itkuaixun.com/post/48.htm

More articles on "yii tinymce syntax highlighting"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/332632.html pageno: 11.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.