CodeIgniter Forums
Integrating CKFinder / Load .html with view() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Integrating CKFinder / Load .html with view() (/thread-76338.html)



Integrating CKFinder / Load .html with view() - elserra - 05-04-2020

Hi everybody,

I am trying ot integrate CKFInder in my app. Some questions will be directly CKFinder related, other will be broader, like the first one.

I stored the php connector in my server (as in the docs), but under \App\ThirdParty\ckfinder. Now I want to access teh sample sites, i.e. \App\ThirdParty\ckfinder\samples\ckeditor.html.

How do I do that? How do I route to a direct html file? I tried via closures, but it does not even parse:

PHP Code:
$routes->group('ckfinder', ['namespace' => 'App\ThirdParty\ckfinder\samples'], function($routes){
    $routes->get('full-page-open.html', function (){
        view('full-page-open.html');
    }); 



How to returrn a .html file - elserra - 05-05-2020

Hi there,

I am trying to show a .html File located under ThirdParty. I am also not able to show the file if it is under View using the view method.

I tried this:

PHP Code:
$routes->get('/ckfinder',function (){
            view(ROOTPATH'app/ThirdParty/ckfinder/samples/full-page-open.html');
        }); 
and I get the exception: Invalid file: /var/www/html/blog/app/ThirdParty/ckfinder/samples/full-page-open.html 

If I store it under Views and call:
PHP Code:
$routes->get('/ckfinder',function (){
            view('full-page-open.html');
        }); 
I get a blank page with the Toolbar


RE: Integrating CKFinder - jreklund - 05-05-2020

Please keep it to the same thread, it's the same issue. I have now merged your thread a second time.


RE: Integrating CKFinder - elserra - 05-05-2020

(05-05-2020, 11:19 AM)jreklund Wrote: Please keep it to the same thread, it's the same issue. I have now merged your thread a second time.
Aaah, ok. I thought I posted it to myself as an answer, that's why... My bad.


RE: Integrating CKFinder / Load .html with view() - elserra - 05-06-2020

For anyone wondering, I made some progress:

new route in Config/Routes.php:
PHP Code:
$routes->group('ckfinder',function($routes) {
    $routes->get('''CKFinderController::index');
    $routes->get('/samples/(:any)''CKFinderController::index/$1');    
    $routes
->get('(:any)''CKFinderController::index/$1');    
}); 

New Controller in Config/Controllers:
PHP Code:
class CKFinderController extends BaseController{
    public function index($folder 'samples'$page 'full-page-open.html')
    {
        $view = \Config\Services::renderer();
        $namespace APPPATH.'ThirdParty/ckfinder/';
        return file_get_contents($namespace.$folder."/".$page);
    }

I am wondering if there is a better way than file_get_contents for returning a .html, .css, .js & co. files as is...

I also seem to have some trouble running JS. An intended messagebox appears, but no content...