sterling
sterling

Reputation: 625

Dynamically set TinyMCE file path for file browser and image viewier using PHP

I am using tincymce as the content editor and file manager in a PHP admin area. How can I change the file path dynamically so that I can use one instance of the editor for different organized functions?

I can easily pass a variable to the tinymce.init configuration, but I am not aware of and can not find a configuration option for the file path.

The actual file path variable is in the plugin's config.php file as $mcFileManagerConfig['filesystem.path'] and $mcFileManagerConfig['filesystem.rootpath']

How can I pass my variable to this file?

Upvotes: 2

Views: 6267

Answers (3)

Matias P.
Matias P.

Reputation: 64

I think that the CI Library Class linked below solves all of those issues and beautifully integrates with CodeIgniter.

It has been rewritten to solve the problem of using sessions inside a plugin, instead of using it inside the controller and the configuration is setted on load, or using "setConfig", so it solves two main problems: Security and Configuration.

So, the configuration and the security are responsibilities of the CI controller, and the image treatment is responsibility of the Image Manager (The site is in Russian, and is not related with me).

Download the CI Library Class

Some code improvements also are in this CI Library class:

Multilingual: Spanish, English, Russian and French.
The setConfig method allows to change the configuration at any time, also supports the use of your own messages.

I use it with CodeIgniter 2.1.3. The only problem with this plugin is the doc that is inexistent.

Controller example:

class Admin extends CI_Controller 
{ 
    public function __construct() 
    { 
        parent::__construct(); 
    } 

    public function mediaUpload() 
    { 
        // Add security checks 

        $config = array( 
            'ImagesPath' => '/images/uploads', 
            'FilesPath' => '/images/uploads', 
            'Path' => '/images/uploads' 
        ); 
        $this->load->library('TinyImageManager', $config); 
    } 
}

Upvotes: 0

Jasper Tey
Jasper Tey

Reputation: 11

You can override the rootpath at any time, dynamically, via:

$_SESSION["filemanager.filesystem.rootpath"] = "/somedynamicdir";

Upvotes: 1

Phil Sturgeon
Phil Sturgeon

Reputation: 30766

Create yourself a mall view that is just for wysiwyg configuration. Then you can assign specific properties to TinyMCE instances based on the textarea names.

http://pastie.org/853208

There should be plenty of code in there for you to look through. As long as that view is included in the head, your TinyMCE setups should all work perfectly and all be different.

Upvotes: 2

Related Questions