Answer the question
In order to leave comments, you need to log in
MVC php how to pass title from view?
How do I pass the title from the view to the main template with $this->title = 'Title'; how it is done in yii2. And just how easy is it to pass data to the view?
This is how I'm putting together the page so far. Maybe here, too, tell me what can be finalized with a file
public function createView($path, $layout = 'index') {
if(file_exists($path)) {
require_once $_SERVER["DOCUMENT_ROOT"] . '/core/views/layout/' . $layout . '.php';
require_once $path;
} else {
View::pageNotFound();
}
}
Answer the question
In order to leave comments, you need to log in
It is not very clear "who stood on whom", but the piece of code above is most likely more convenient to bring to the form:
public function createView($path, $layout = 'index')
{
if(!file_exists($path)) {
View::pageNotFound();
}
$this->layout = $layout;
$someParamsToSendIntoTheView = [...];
return $this->render($path, $someParamsToSendIntoTheView);
}
$this->params['my-parameter'] = 'Some Data';
$this->params['my-parameter']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question