search
HomeBackend DevelopmentPHP Tutorialthinkphp3.0 中的thinkeditor怎么用

一直纠结于thinkphp中怎么加载编辑器,最新我看就thinkphp3.0中tool工具中带了一个thinkeditor。但是一直的不知道怎么配置,那个高手能给详细的给我配置下吗?谢谢了


回复讨论(解决方案)

他不是有说明文档吗?

首先,介绍下本编辑器:
  本编辑器是thinkphp(简称tp)官方2010年某位大侠所创架构、用jquery写的,后又经历成立夫之手完成,我只是写了标签库、及本日志,本人接手后,水平有限、又没 有时间,尚未搞懂它的具体流程,今后将由左家梓(网名麦当苗儿)这位曾经和kindeditor官方人员接触的js大侠完善,当然网友也可以贡献力量,提 出建议,和贡献插件。

其次,使用thinkeditor必须注意三个地方:
  1.本编辑器只适用于tp(上传的地方TP写法,其他框架使用自行修改)。js部分的引用写成了标签库。
  2.使用本编辑器的人都要有大无畏的冒险精神,爱折腾,因为本编辑器尚未完善,不能称的上专业。
  3.本编辑器只提供大部分网站基本的编辑器的功能,排版、文章中能显示图片flash;插入视频插件未开发。有待广大网友的鼎力帮助。

如何使用本编辑器?
  首先,下载整个编辑器的压缩包。
  然后,解压,将thinkeditor文件夹放入你的项目公共资源目录/Public下。
并将其中的标签TagLibTp.class.php放入项目的Lib\TagLib\下,并根据框架版本在配置中配置引入的插件路径。(2.2和3.0使用方式会有不同)。
  再然后,在模板引用的地方加上
在head位置加上

这里先说几个参数id是你要替换的textarea的id,uploadURL是上传处理的方法,width是编辑器的宽,可以以px表示,也可以用百分表表示 如width = "100%",因此要单位,其他的参数不需要写单位的。
其他参数的话,参考标签库和说明文档。
然后给项目添加编辑器的上传方法。
如blog中的PublicAction.class.php中的写法
public function editor_up(){
        //$savePath 为项目下的上传目录名 如 uploads 会是 上传到__ROOR__/uploads下,为空则上传到__ROOT__/uploads/thinkeditor下 
// $saveRule为上传文件命名规则,例如可以是 time uniqid com_create_guid 等,例如可以是 time uniqid com_create_guid 等 默认为time参考tp的上传类
// 例如可以是 time uniqid com_create_guid 等
        $savePath = 'uploads';
        $saveRule = 'time';
        import("@.ORG.UploadFile");
        $savePath = ($savePath)? './'.$savePath : './Uploads/thinkeditor';
        $savePath = (substr($savePath,-1)!='/')?$savePath.'/':$savePath;
        $maxSize = ($_POST['temaxsize'])? $_POST['temaxsize'] : -1;
        $upload = new UploadFile($maxSize,'','',$savePath,$saveRule);
        
        //传给js的参数 $savepath是上传的文件的生成路径,$isupload是上传是否成功的布尔值
        $savepath = '';
        $isupload = 'false';
        if(strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
            $info = $upload->uploadOne($_FILES['teupload']);
            if($info){
                $isupload = 'true';
                $savepath = $upload->savePath.$info[0]['savename'];
                $savepath = substr($savepath, 1);
            }else{
                $error = $upload->getErrorMsg();
            }
        }
        import('@.TagLib.TagLibTp');
        //上面的上传只是写个例子,用户上传可以自定义的,但是下面的是传给编辑器的
        //参数必须为$isupload,是否成功,上传后的文件相对路径$savepath必须相对于项目根目录的,错误信息
TagLibTp::think_upload($isupload,$savepath,$error);
}

有能力的童鞋可以自己写上传方法,只要最后自己调用TagLibTp::think_upload($isupload,$savepath,$error);传入对应的参数即可,就可以使用本编辑器了。效果如图:
 
本编辑器内写了的自动刷新,保存文本时就不用调用方法保存了。还有标签调用时写了jquery的防冲突模式,因此其他类库可以与之同时使用。

至于插件的开发,看说明文档。我在plugins\system.js里写了个实现弹窗输入thinkphp的eq标签的
name 和value值后生成thinkphp eq 标签的插件,去掉注释,在thinkeditor.js里defaults配置里controls里加上eq,
 
这行去掉注释,应该就能出来了。不过我没加样式,用的html源码的图标。开发起来不难的,相信凭着大家的创造力,可以开发出很多编辑器的插件的.。
                   谢谢您的支持,thinkphp官方组
愿您过个好年!   2012年1月15日


3.0中不是extend里面有一个tool文件夹 里面自带了thinkeditor   还需要导入吗?

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

How to Register and Use Laravel Service ProvidersHow to Register and Use Laravel Service ProvidersMar 07, 2025 am 01:18 AM

Laravel's service container and service providers are fundamental to its architecture. This article explores service containers, details service provider creation, registration, and demonstrates practical usage with examples. We'll begin with an ove

Customizing/Extending Frameworks: How to add custom functionality.Customizing/Extending Frameworks: How to add custom functionality.Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft