【问题标题】:Implementing Tinymce in my CodeIgniter app在我的 CodeIgniter 应用中实现 Tinymce
【发布时间】:2013-11-19 08:25:25
【问题描述】:

所以我正在创建一个简单的 CMS 供我自己使用。所以很明显我想用 Tinymce 来编辑我的文本。我试图在一个简单的视图中实现它,但它什么也没返回。控制台中没有错误,但它不会加载 Tinymce。

我遵循了这个简单的 CI 指南:

https://github.com/EllisLab/CodeIgniter/wiki/TinyMCE

所以这是我的简单观点:

<html>
<head>
<title>TEST</title>
<script type="text/javascript" src='<?php echo asset_url()."js/jquery.js" ?>'></script>
<script type="text/javascript" src='<?php echo asset_url()."js/tiny_mce/tiny_mce.js" ?>'>
    tinyMCE.init({
        theme : "advanced",
        mode : "textareas",
        plugins : "imagemanager,filemanager,insertdatetime,preview,emotions,visualchars,nonbreaking",
        theme_advanced_buttons1_add: 'insertimage,insertfile',
        theme_advanced_buttons2_add: 'separator,forecolor,backcolor',
        theme_advanced_buttons3_add: 'emotions,insertdate,inserttime,preview,visualchars,nonbreaking',
        theme_advanced_disable: "styleselect,formatselect,removeformat",
        plugin_insertdate_dateFormat : "%Y-%m-%d",
        plugin_insertdate_timeFormat : "%H:%M:%S",
        theme_advanced_toolbar_align : "left",
        theme_advanced_resize_horizontal : false,
        theme_advanced_resizing : true,
        apply_source_formatting : true,
        spellchecker_languages : "+English=en",
        extended_valid_elements :"img[src|border=0|alt|title|width|height|align|name],"
        +"a[href|target|name|title],"
        +"p,"
        invalid_elements: "table,span,tr,td,tbody,font"

    });
</script>

</head>
<body>
<textarea>
    text..
</textarea>
</body>
</html>

我现在看到的是标准文本区域,而不是 Tinymce 编辑器。由于控制台根本没有给我任何反馈,我有点不知道在哪里寻找问题。

有人有这方面的经验吗?

【问题讨论】:

    标签: javascript php codeigniter tinymce


    【解决方案1】:

    使用此脚本更改 tinymce 的文本区域:

    $(document).ready(function() {
        tinymce.init({
                selector: "textarea",
                plugins: [
                    "advlist autolink lists link image charmap print preview anchor",
                    "searchreplace visualblocks code fullscreen",
                    "insertdatetime media table contextmenu paste"
                ],
                toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | fontselect fontsizeselect",
                fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt"
            });
    
        });
    

    希望对你有帮助

    【讨论】:

    • 我仍然一无所获。也没有错误。它只显示标准文本区域
    • @SupSonツ 你能用 chrome 浏览器检查并检查元素,点击网络选项卡,看看是否加载了 tinymce 脚本。我看到你错过了 标签和
    • tiny_mce.js 和 jquery.js 也加载得很好:)
    【解决方案2】:

    我添加了缺少的开始标签。立即尝试。

    <html>
    <head>
    <title>TEST</title>
    <script type="text/javascript" src='<?php echo asset_url()."js/jquery.js" ?>'>  </script>
    <script type="text/javascript" src='<?php echo asset_url()."js/tiny_mce/tiny_mce.js" ?>'>
    <script>
        tinyMCE.init({
            theme : "advanced",
            mode : "textareas",
            plugins : "imagemanager,filemanager,insertdatetime,preview,emotions,visualchars,nonbreaking",
            theme_advanced_buttons1_add: 'insertimage,insertfile',
            theme_advanced_buttons2_add: 'separator,forecolor,backcolor',
            theme_advanced_buttons3_add: 'emotions,insertdate,inserttime,preview,visualchars,nonbreaking',
            theme_advanced_disable: "styleselect,formatselect,removeformat",
            plugin_insertdate_dateFormat : "%Y-%m-%d",
            plugin_insertdate_timeFormat : "%H:%M:%S",
            theme_advanced_toolbar_align : "left",
            theme_advanced_resize_horizontal : false,
            theme_advanced_resizing : true,
            apply_source_formatting : true,
            spellchecker_languages : "+English=en",
            extended_valid_elements :"img[src|border=0|alt|title|width|height|align|name],"
            +"a[href|target|name|title],"
            +"p,"
            invalid_elements: "table,span,tr,td,tbody,font"
    
        });
    </script>
    
    </head>
    <body>
    <textarea>
        text..
    </textarea>
    </body>
    </html>
    

    【讨论】:

    • 嘿。那也没有解决它。它已经在 js/tiny_mce/tiny_mce.js 文件的脚本标签中了 :)
    • 你能上传到某个网站并给我网址,以便我识别问题。因为您正在加载很多主题,而我无法使用它。我试着在jsfiddle.net/zM5Vp 做一个小提琴你可以更新同样的
    【解决方案3】:

    只需将此行添加到标题

    <!-- WYSIWYG text editor -->
    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>tinymce.init({ selector:'textarea' });</script>
    

    【讨论】:

      猜你喜欢
      • 2012-06-23
      • 1970-01-01
      • 2011-01-23
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 2015-03-11
      相关资源
      最近更新 更多