Luigi Forlano
Luigi Forlano

Reputation: 1

Running an external PHP script within a page of Octobercms

to speed up the creation of a CRUD interface in the frontend I am trying to use an external tool/program called PDOCrud within octobercms (PHP 7.2). PDOCrud does perfectly its job when works alone but I am facing problem to integrate it in Octobercms (I hope it can be integrated).

This is the normal code of PDOCrud to render a crud interface:

 require_once base_path('script/pdocrud.php'); 
 $pdocrud = new PDOCrud();
 echo $pdocrud->dbTable("tablename")->render(); 

This is how I included it in a normal page

title = "Make tournament"
url = "/make-tournament"
layout = "Default"
description = "some description"
is_hidden = 0
==
<?php
function onstart() { 
  require_once base_path('script/pdocrud.php'); 
  $this['crud'] = new class {
        public function foo() {
            $pdocrud = new PDOCrud();
            return $pdocrud->dbTable("tablename")->render(); 
            // return phpinfo();
        }
    };
}
?>
==
<h1>Make crud</h1>
{{ crud.foo()|raw }}

The form appears. But the buttons for crud operations does not perform any actions. Perhaps the session of octobercms collide with that of the external code, or jquery that it is loaded perhaps two times. Does anybody tried a similar approach and solved the problem?

EDIT: I tried the suggestions but it did not work for me, maybe I missed something. Just few hours ago the author of the external program made un upgrade and my previous code worked perfectly. I am aware of not using properly the framework but I need a workaround to face a deadline. Thanks to all of you!

Upvotes: 0

Views: 457

Answers (1)

LukeTowers
LukeTowers

Reputation: 1291

Using PDOCrud for this purpose is overlooking a significant amount of the features that are built into OctoberCMS. It would be very simple to create a custom plugin for yourself and integrate the incredibly powerful and easy to use backend forms in a component to use on your frontend.

See

Upvotes: 1

Related Questions