Variables for extension of twig blocks

0

Hello

I'm starting to adopt the MVC framework in my PHP projects and for this, I'm using Twig, so I understand I can not call more than one view at a time, so I call a view from the requested controller and it extends the others, just use the includes in php.

But the difficulty I'm encountering is as follows, how do I pass data out of the block. for example, when I call the course view it does {% extends '/layout/index.html'%} in the index.html has headar and footer include, for normal php I always carry a variable that will display the data but not I understand how to do this using the twig because of the way each view is called. the only way I found it is to call this data to the site title example in a function in all my controller, but I find this very repetitive, I would like to know which is the most correct way I thought of calling the bootstrap.php or file config.php, but I do not know how to pass this to twig, because as I understand I can not instantiate more than one view.

It follows the structure of my project, if necessary put more photos to explain better, seen my little understanding do not know if the question was clear.

IsolvedtheproblembyloadingthedatathroughtheBaseControllerandcallingineachcontroller,butnowIhaveanotherproblem,IcanonlypassthedatainanarraycreatedinthehandintheBaseController,Icannotcallafunctionofmymodeltomakethesearchofdatainthedatabase,phpdoesnotleave,woulditbeanylimitationbecauseitisanabstractclass?

lines13and14donotwork,onlythearray,theimageerror,butIdonotknowwhy,thiscodeworksperfectlyonanothercontroller.

    
asked by anonymous 24.11.2018 / 19:19

0 answers