Welcome Guest, Not a member yet? Register   Sign In
Can't Find A Way To Configure Any TinyMCE Image Upload Plugin [NOOB]
#1

[eluser]Swammy[/eluser]
Hey guys. I'm relatively new to CI but I am enjoying it alot.

I have built a rather robust form that uses TinyMCE to fix the markup. One of my needs is to have images be uploaded rather than hotlinked.

I have attempted to run multiple different TinyMCE Upload plugins but all seem to have path configuration issues or Apache blocks whathaveyou.

When reading the CI documentation I seem to remember something about uploading but I don't really follow it.

Is there something I'm not doing? Perhaps something with Routes or .htaccess? Is there a recommended TinyMCE upload method with CI?

Thanks in advance.
#2

[eluser]gRoberts[/eluser]
For most of my projects I have been using http://www.phpletter.com/Demo/Tinymce-Aj...e-Manager/ with a few changes in the implementation (for authentication purposes).

Works well Wink
#3

[eluser]Swammy[/eluser]
[quote author="gRoberts" date="1336732488"]For most of my projects I have been using http://www.phpletter.com/Demo/Tinymce-Aj...e-Manager/ with a few changes in the implementation (for authentication purposes).

Works well Wink[/quote]

Are you able to give me a few details as to what you needed to do to configure it to work with CI?
#4

[eluser]daniel ispas[/eluser]
I also use tinyMCE with file browser. It's quite easy to implement using CI. Check if the folder where you have tinyMCE and the upload plugin is available (you don't get redirects from .htaccess) and then make sure all of the javascript files get loaded (you may have to change a few things in config.php in tinyMCE to make it all work).
#5

[eluser]Swammy[/eluser]
[quote author="daniel ispas" date="1336827781"]I also use tinyMCE with file browser. It's quite easy to implement using CI. Check if the folder where you have tinyMCE and the upload plugin is available (you don't get redirects from .htaccess) and then make sure all of the javascript files get loaded (you may have to change a few things in config.php in tinyMCE to make it all work).[/quote]

Thanks Daniel. Unfortunately that hasn't helped me. Furthermore the AJAX File Manager demo is broken for some reason and I cannot seem to find any tutorial for something that lets you manage files in TinyMCE and CI

Sad
#6

[eluser]daniel ispas[/eluser]
You could use CKEditor with CKFinder to replace tinyMCE. It's easier to implement than tinyMCE and you don't need to buy a file browser as CKFinder is free.
Here is a link to integration class: http://ellislab.com/forums/viewthread/150607/

Hope this helps
#7

[eluser]Swammy[/eluser]
[quote author="daniel ispas" date="1337160183"]You could use CKEditor with CKFinder to replace tinyMCE. It's easier to implement than tinyMCE and you don't need to buy a file browser as CKFinder is free.
Here is a link to integration class: http://ellislab.com/forums/viewthread/150607/

Hope this helps[/quote]

Thanks. This helps a little. But I can't seem to actually upload a file. The path appears and the folders all have been CHMODed. Why wouldn't it actually upload?

integration class?
#8

[eluser]daniel ispas[/eluser]
This is the helper file I use to integrate CK.
Code:
<?php
if(!defined('BASEPATH')) exit('No direct script access allowed');

/*
* CKEditor helper for CodeIgniter
*
* @author Samuel Sanchez <[email protected]> - http://www.kromack.com/
* @package CodeIgniter
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/us/
* @tutorial http://www.kromack.com/codeigniter/ckeditor-helper-for-codeigniter
* @see http://ellislab.com/forums/viewthread/127374/
*
************************************************
* CKFinder Integration                         *
************************************************
* Improvements by Carlos Alcala from UAR Software
*  [email protected]
*/
function display_ckeditor($data)
{
    $return = '[removed][removed]';
    $return .= '[removed][removed]';

    //Adding styles values
    if(isset($data['styles'])) {
        
        $return .= "[removed]CKEDITOR.addStylesSet( 'my_styles', [";
  
        
        foreach($data['styles'] as $k=>$v) {
            
            $return .= "{ name : '" . $k . "', element : '" . $v['element'] . "', styles : { ";

            if(isset($v['styles'])) {
                foreach($v['styles'] as $k2=>$v2) {
                    
                    $return .= "'" . $k2 . "' : '" . $v2 . "'";
                    
                    if($k2 !== end(array_keys($v['styles']))) {
                         $return .= ",";
                    }
                }
            }
        
            $return .= '} }';
            
            if($k !== end(array_keys($data['styles']))) {
                $return .= ',';
            }            
            

        }
        
        $return .= ']);[removed]';
    }  
    
    //Building Ckeditor
    
    $return .= "[removed]
         CKEDITOR_BASEPATH = '" . base_url() . $data['path'] . "/';
        CKEDITOR.replace('" . $data['id'] . "', {";
    
            //Adding config values
            if(isset($data['config'])) {
                foreach($data['config'] as $k=>$v) {
                    
                    $return .= $k . " : '" . $v . "'";
                    
                    if($k !== end(array_keys($data['config']))) {
                        $return .= ",";
                    }                        
                }
            }              
                    
    $return .= '});';
    $return .= "CKEDITOR.config.stylesCombo_stylesSet = 'my_styles';";

    //CKFINDER INTEGRATION
    $return .= "CKFinder.SetupCKEditor( null, { BasePath : '" .base_url(). $data['ckfinder']['path']."', RememberLastFolder : false } ) ;";
    $return .= "if (CKEDITOR.instances['" . $data['id'] . "']) {CKEDITOR.remove(CKEDITOR.instances['" . $data['id'] . "']);}";
    //FINISH SCRIPT
    $return .= "[removed]";
    
    return $return;
}

In controller you should have:

Code:
$this->load->helper('ckeditor');
         //Ckeditor's configuration
         $this->editor['ckeditor'] = array(
             //ID of the textarea that will be replaced
             'id'     =>     'content',     // Must match the textarea's id
             'path'    =>    'js/ckeditor',    // Path to the ckeditor folder relative to index.php
             //Ckfinder's configuration
             'ckfinder' => array(
             'path'    =>    'js/ckfinder',    // Path to the ckeditor folder relative to index.php
             ),
             //Optionnal values
             'config' => array(
                 'toolbar'     =>     "Full",     //Using the Full toolbar
                 'width'     =>     "810px",    //Setting a custom width
                 'height'     =>     '200px',    //Setting a custom height
             ),
            
         );

In view:

Code:
&lt;?php echo display_ckeditor($ckeditor); ?&gt;
This goes after the textarea.

If upload doesn't work make sure you have set $baseurl and $baseDir in CKFinder-> config.php
#9

[eluser]Unknown[/eluser]
@Daniel ispas : How do you handle authentication in CKFinder, in its config.php file CheckAuthentication function ?

We have a setup where Session is in database, and session cookie is encrypted and we would like to keep it that way, so for now we have not found a solution which we could keep CI session and authenticate in ckfinder.




Theme © iAndrew 2016 - Forum software by © MyBB