Call PHP Script in Editor::inst Class
Call PHP Script in Editor::inst Class
pcnweb
Posts: 4Questions: 1Answers: 0
What's the "Editor" way of calling an external PHP script inside one of the Editor::inst "on" statements?
Ex, "runThis" pseudocode:
->on( 'preCreate', function ( $editor, $values ) {
// On create update all the other records to make room for our new one
$editor->db()
->query( 'update', 'mobilemenu_fbgt' )
->set( 'roworder', 'roworder+1', false )
->where( 'roworder', $values['roworder'], '>=' )
->exec();
->runThis(file_get_contents('my/file/path.php') )
} )
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There are examples in the documentation:
https://editor.datatables.net/manual/php/events
So according to that, I added a simple function above the Editor::inst -
function updateVOD(){
$myvar = file_get_contents('http://path/to/my/file.php');
}
and appended these to the Editor::inst, after my preCreate and preRemove (which work):
No dice, postCreate and postRemove don't fire.
Where is a working example?
Should I just call my custom function in the end of the preCreate and preRemove blocks?
Ok, totally wrong - moving the function call does nothing. Out of ideas for now.
Hi,
What do you want to do with the contents of the PHP file?
This code:
would simply get the contents of the response (possibly a failure in this case since you are using http:// rather than a local file), and assign it to $myvar, which isn't then used.
If you want to execute the PHP code in your file you would use
include
- e.g.:I would suggest that a better pattern would be to define the
updateVOD()
function in your external file and then alwaysinclude
it at the top of the main PHP file.Allan