• Home
  • Examples
  • Integrations
  • Integrate filebrowser in Joomla CMS

Integrate filebrowser in Joomla CMS

The text editor can be easily integrated with Joomla. For this purpose there is a special plug-in, but sometimes you just need to embed the editor in your site and use filebrowser. You can use Jodit official php connector Install this connector

composer create-project --no-dev jodit/connector

Change file in connector folder config.php with the following code:

return [
    'sources' => [
        'default' => [
            'root' => JPATH_BASE.'/images/',
            'baseurl' => '/images/',
            'extensions' => ['jpg', 'png', 'gif', 'jpeg'],
        ]
    ]
];

And change Application.php

define('_JEXEC', 1);
define('JPATH_BASE', realpath(realpath(__DIR__).'/../../../../../')); // replace to valid path
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';

$app = JFactory::getApplication('site');

class JoditRestApplication extends \jodit\JoditApplication {
    function checkPermissions() {
        $user = JFactory::getUser();
        if (!$user->id) {
            trigger_error('You are not authorized!', E_USER_WARNING);
        }
    }
}

After that you can use this connector in Jodit

new Jodit('#editor', {
    uploader: {
        url: '/somefolder/connector/index.php?action=upload'
    },
    filebrowser: {
        ajax: {
            url: '/somefolder/connector/index.php'
        }
    }
})

That is all. This code protect your site from unauthorized uploding files.