daveh / php-mvc

A simple PHP model-view-controller framework, built step-by-step as part of the "Write PHP like a pro: build an MVC framework from scratch" course on Udemy.
https://davehollingworth.com/go/phpmvc/
MIT License
782 stars 311 forks source link

twig include error #93

Closed roobiniano closed 3 years ago

roobiniano commented 3 years ago

Hi Dave, how are you?

I am trying to include some templates (eg header) in my base.html but it is giving me a fatal error (template not found). The paths are ok and the file names too. I tried with the .html and .twig extensions but it gives the same error.

Is there something I need to keep in mind?

example code:

<body>
        {% include 'template-parts/header.html' %}

        {% block body %}{% endblock %}
</body>

thanks again

daveh commented 3 years ago

include is based on the path to the views folder, so the above line will look for the file views/template-parts/header.html - is that where the file is located?

roobiniano commented 3 years ago

include is based on the path to the views folder, so the above line will look for the file views/template-parts/header.html - is that where the file is located?

Hi Dave, yes, the files are there, the error was that I was including the files with relative paths, thank you very much!