2012-06-15 151 views
0

我有一个关于在CakePHP中实现所见即所得编辑器的问题。我正在为我工​​作的员工开发一个内部网。我目前正在使用CakePHP 1.3。我发现这个仓库CakePHP和WYSIWYG编辑器

https://github.com/josegonzalez/cakephp-wysiwyg-helper/tree/1.3

其中包含捆绑在一起的几个不同的所见即所得的编辑器。我遵循指示,并确保我下载了NicEdit的JS发行版(与TinyMCE一起,在我与NicEdit挣扎后,仍然没有任何作品)。

我在我看来运行

echo $this->Nicedit->input('content'); 

。当我在浏览器中加载页面时,输入框会正确显示,但是没有用于文本编辑的工具栏。在该页面时运行脚本的检查,这个代码块下

<div class="input textarea required"><label for="AnnouncementContent">Content</label><textarea name="data[Announcement][content]" cols="30" rows="6" id="AnnouncementContent" ></textarea></div><script type="text/javascript"> 
     var area1; 
     function makePanel() { 
      area1 = new nicEditor({fullPanel : true}).panelInstance(
       'AnnouncementContent', 
       {hasPanel : true} 
      ); 
     } 
     bkLib.onDomLoaded(function() { makePanel(); });</script>  

我收到此错误:未捕获的ReferenceError:bkLib没有定义

我已经花了几个小时试图解决这一问题没有无济于事。有没有人有解决这个问题的一些见解?

回答

0

下面是如何设置的TinyMCE在最近的1.3项目,不使用该插件:

从我的观点,即使用TinyMCE的编辑器:

//tell template to include the tinyMCE javascript file 
<?php 
if(isset($javascript)): 
    echo $javascript->link('tiny_mce/tiny_mce.js'); 
endif; 
?> 

//Build the form I need 
<div class="responses form"> 
<?php echo $this->Form->create(null, array('controller' => 'Responses', 'action' => 'add')); ?> 
    <fieldset> 
     <legend>Add Response</legend> 
    <?php 
     echo $form->hidden('listing_id', array('value' => $tempid)); 
     echo $this->Form->input('content'); 
    ?> 
    </fieldset> 
<?php echo $this->Form->end(__('Submit', true));?> 
</div> 

//set up the editor 
<script type="text/javascript"> 
    tinyMCE.init({ 
     theme : "simple", 
     mode : "textareas", 
     convert_urls : false 
    }); 
</script> 

我知道这是不是真的回答你问题是否真的想要使用该插件,但如果您只使用TinyMCE就可以了,您可以用这种方法很容易地设置它。最好的部分是,它会自动转换为HTML,以便您可以保存到数据库。当您从数据库中检索数据时,它将采用正确格式化的HTML,因此您可以轻松显示它。

根据您希望使用哪个文本区域,您也可以在init方法中更具体。我很难让它只在特定的文本区域激活,但你可能会有不同的运气。该文档是here。您还可以打开更高级的主题。文档介绍了这些选项。