hello in one of my custom files i use the following code to include mas dashboard report:
<?php
include "Dashboard1dsb.php";
?>
in 2021 show this error:
Warning: include(Dashboard1dsb.php): failed to open stream: No such file or directory in C:\xampp\htdocs\2021\views\Home.php on line 157
Warning: include(): Failed opening ‘Dashboard1dsb.php’ for inclusion (include_path=‘C:\xampp\php\PEAR’) in C:\xampp\htdocs\2021\views\Home.php on line 157
As the error message said: “failed to open stream: No such file or directory in …”, this error is caused because of the “Dashboard1dsb.php” file does not exist in the “views” sub-folder.
Hello, i think with this update the php include method change, i reset the full project, create a dashboard report and a sumary report, both work separate , but if i try to include in a php file as we include in 2020:
<?php include_once "homepagereport.php"; // Includes an external file ?>
always show error : An internal error has occurred while processing your request.
so i am sure something change here and as show in help file do not work anymore
now i did a simple test
i create a page in views named webform.php with the test code:
<?php
echo "Hello World!";
?>
in custom file i put <?php include_once "views/webform.php"; // Includes an external file ?>
the page load fine and show Hello World
but i add the dashboard report, page show error, if i go to dashboard directly i can see the dashboard report, so in resume just fail when add dasboard report to a custom file, in 2020 work fine
Please see the error detail from the *.log file inside the “log” sub-folder under the root of your web application. Please post the error here for more discussion.
Because in the generated Custom file, there is no showPageHeader and showPageFooter methods available. That’s the cause why the error occured. So, to avoid this error, we need to remove the methods from the generated Report file.
Note that v2021 uses Routing, behind the scenes it is a more advanced architecture, MVC (Model View Controller). You can learn more here: http://www.slimframework.com/docs/v4/.
In the old/traditional architecture, each .php file includes other required files and runs by itself, so you might in turn include other .php file (if there are no conflicts). But in MVC it is different, you need to think differently. Each “page” has its separate class, controller and view files. You cannot include a view in another view without instantiating the class of the view. Your “Hello World” works because it is simple PHP code without a class. If you include another view, you need to create its class first.
ok thanks, but in simple words , what could be a solution to insert the dashboard in a custom file,is there any simple way? remember we use phpmaker because we are not expert in php
You cannot include a view in another view without instantiating the class of the view.
You just create the object of the class first, e.g.
//$OldPage = $Page; // Uncomment to backup the original $Page if you need to resume the page later
$Page = new HomePage(); // Create the instance
include_once “homepagereport.php”; // Include the view
//$Page = $OldPage; // Uncomment to resume the page if there are original content below