The function below doesn't seem to work correctly. In the function load_module I am using the require()
function in PHP to get the file from Modules Folder.
What am trying to do is, check if file is in the modules folder, if its exist then run the require_once()
function. When I try with the file on the modules folder its works great, then what I did was removed the file and then tried again it gave me this error:
Warning: require_once(xxxxxxxxxxxxxxxxxxxxxxx): failed to open stream: No such file or directory in D:\xampp\htdocs\projects\hoplate\admin\components\template.php on line 4
Whereas it should have showed this exception error message:
There was an error, It seems that the moudle doesn't exist in it's location xxxx
Function load_module
function load_module( $_module_file, $require_once = true ) {
if ( $require_once )
if ( require_once( $_module_file ))
require_once( $_module_file);
else
return "There was an error, It seems that the moudle doesn't exist in it's location $_module_file";
else
if( require( $_module_file ) )
require( $_module_file );
else
return "There was an error, It seems that the moudle doesn't exist in it's location $_module_file";
}
Function get_module
/* Get Modules */
function get_module( $_module_slug ){
load_template( ADMIN_PATH . '/modules/' . $_module_slug . '.php');
}
More Information
I have also tried using the file_exists()
function but it still doesn't seem to work.