I have to create a to-do application with PHP using MVC.
It’s obligated to use partials such as header.php, footer.php, …
However, I want to echo the sidebar as an inline element with my main content(.php).
But when I do this it get’s positioned as a column (obviously).
So I tried to render the sidebar.php into the content.php but it didn’t appear and in the browsers console, even funnier, the command that should import the sidebar.php got commented out..
I’m on the edge of just write sidebar content in a container from the content.php and drop the sidebar partial unless some of you can give me a clear way to do this. And with ‘this’, I mean a way to include the sidebar.php into my content so they are partials but inline.
If you want to see some code.. :
this is the index.php in the public folder
require '../resources/views/header.php';
//require '../resources/views/sidebar.php';
require '../App/bootstrap.php';
require '../resources/views/footer.php';
The main content is rendered with a controller through bootstrap.php
This is the controller that renders my main content (which is called application.php)
<?php
namespace AppHttpControllers;
use AppProvidersView;
class MainController {
public function mainApp() {
return View::display('application.php');
}
};
but I’ve written this inside the application.php file:
<?php
include 'sidebar.php';
?>