Answer the question
In order to leave comments, you need to log in
How to form an architecture in a framework?
Hello. Let's say that I decided to make a site on the MVC type framework.
There is a controller: posts , view: posts_view , module: posts_model
There is a controller: users , view: users_view , module: users_model
I write all html code in files: posts_view and users_view .
Question: how would it be possible to implement the loading of the same container <head>
and generally competently place all this in the tag <html>
, and the contents of the views in <body>
.
i.e.
<html>
<head>
//Тут подключаются все нужные мне front-end файлы и выводятся заголовок, мета-теги
</head>
<body>
//Тут я могу подключать виды posts_view или users_view
</body>
</html>
Answer the question
In order to leave comments, you need to log in
ms2345 : did this on CI. <?php $this->view->load('header');?> If I'm not mistaken. And you can't send anything there. But the main thing in the main view in which you call is a string pass the necessary data for output
And it's better to take this code to a separate library and call the function passing parameters to it
$headData['title'] = "";
$headData['keywords'] = "";
$headData['seo_description'] = "";
$headData['scripts'] = array(); // Массив скриптов. Потом во фронте циклом их выгрузить
$headData['styles'] = array(); // Массив стилей. Аналогично выгружать
$data['header'] = $this->CI->load->view('template/header' , $headData , true); //Шапка
$data['footer'] = $this->CI->load->view('template/footer' , array() , true); //Футер
$pageData['pageContent'] = array(); // Какой-то контент для страницы
$data['content'] = $this->CI->load->view('front/*your-page*' , $pageData , true); //Страницу которую грузить в шаблон
$this->load->view('template/'.$template , $data ); //В какой шаблон грузить страницу
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question