How does one include a partial file on a layout file?
I've read and tried tutorials on Views using $this->renderSection and $this->include. It seems to me that $this->include can only be used on view files NOT under a layout file.
I want to trim down my layout files as much as possible so that a change in certain components common to all layout files can be easily changed and maintained.
Consider the following file structure:
Code:
Views
|>layout
>partials
-head.php
-master.php
This is the content of head.php:
Code:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
This is the content of master.php:
Code:
<?php $this->include('partials/head.php'); ?>
<title>Site Title</title>
</head>
<body>
<!--Area for dynamic content -->
<?= $this->renderSection("content"); ?>
</body>
</html>
Running the controller in a browser I get 'CodeIgniter\View\Exceptions\ViewException
Invalid file: head.php '
If I move head from partials to the same directory as master.php, I get the same error. The only way I can make it work is to remove the $this-> and make include a PHP include.
Am I doing something wrong?