TinyMCE和CakePHP

时间:2010-09-09 15:54:45

标签: cakephp tinymce

我正在使用cakephp tinymce helper。我知道我可以改变简单和高级等主题。我想知道是否可以更进一步,并明确设置用户可以选择的不同字体等?

那么,如果我只希望用户能够使用段落标签和预标签?

3 个答案:

答案 0 :(得分:1)

嘿,琼斯,我觉得这个页面解释得比我好! http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements

如果您希望允许用户使用某些CSS标记,您可以使用以下行:

theme_advanced_buttons1: "styleselect, ...whatever other advanced buttons you'd like on line 1"

content_css: "location of stylesheet that contains the options you would like to provide"
在你的init函数中

希望这有帮助!

答案 1 :(得分:1)

我不使用帮助者(不知道有一个)。我只是将init代码放在一个元素中,并将其包含在我需要的地方。见:http://book.cakephp.org/2.0/en/views.html#elements。如果您需要能够指定不同的配置,可以将数组传递给元素,然后将值回显到javascript中,如:

    <script type="text/javascript">
        $().ready(function() {
            $('textarea').tinymce({
                // Location of TinyMCE script
                //          // General options
                theme : "advanced",
                plugins : "<?php echo $pluginsString ?>",
                ...
    </script>

我就是这样做的:

<?php
echo "\n".$javascript->link('jQuery/jquery-1.3.2',false);
echo "\n".$javascript->link('tiny_mce/jquery.tinymce.js',false);
echo "\n".$javascript->link('tiny_mce/tiny_mce.js',false);
?>
<script type="text/javascript">


    $().ready(function() {
        $('textarea').tinymce({
            // Location of TinyMCE script
            //          // General options
            theme : "advanced",
            plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

            // Theme options
            theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,fontselect,fontsizeselect,|,image,link,unlink,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,|,pastetext,pasteword,|,fullscreen",
            theme_advanced_buttons2 : "bullist,numlist,|,blockquote,|,anchor,cleanup,code,|,forecolor,backcolor,|,tablecontrols",
            theme_advanced_buttons3 : "",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : true,
            relative_urls : false,
            file_browser_callback : "fileBrowserCallBack"



        });
    });
    function fileBrowserCallBack(field_name, url, type, win)
    {
    //var connector = "../../filemanager/browser.html?Connector=connectors/php/connector.php";
    var connector = "<?php echo Router::url('/js') ?>/tiny_mce/filemanager/browser.html?Connector=connectors/php/connector.php";
    var enableAutoTypeSelection = true;

    var cType;
    tinyfck_field = field_name;
    tinyfck = win;

    switch (type) {
            case "image":
                cType = "Image";
                break;
            case "flash":
                cType = "Flash";
                break;
            case "file":
                cType = "File";
                break;
    }

    if (enableAutoTypeSelection && cType) {
            connector += "&Type=" + cType;
    }

    window.open(connector, "tinyfck", "modal,width=600,height=400");
    }
</script>

该回调函数适用于Tiny的Fck文件管理器/加载器插件:http://freshmeat.net/projects/tinyfck/

答案 2 :(得分:0)

您也可以编写自己的Skin并使用tinymce init函数应用它。 有关如何为自己的皮肤编写自己的皮肤的更多信息,请查看this tutorial from moxiecode