Hello, no, you do not need to, nor should you be repeating the same information in all views (such as importing scripts). In your view user you should only worry about what is related to it, that is, with the "core."
There are two solutions that work identically. In both, you need to have bits of view to represent HTML elements like header and footer, for example:
header.php
(view)
<!doctype html>
<html lang="pt">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?=$page_title?></title>
<link rel="shortcut icon" href="<?=site_url('favicon2.ico')?>" type="image/x-icon">
<link rel="icon" href="<?=site_url('favicon2.ico')?>" type="image/x-icon">
<link rel="stylesheet" href="<?=site_url('/css/bootstrap.min.css')?>">
</head>
<body>
footer.php
(view)
<footer class="footer">
<script src="<?=site_url('js/jquery.min.js')?>"></script>
<script src="<?=site_url('js/bootstrap.min.js')?>"></script>
<script>
<!-- Por exemplo um script só para uma view em específico -->
<?=$page_script?>
</script>
</footer>
</body>
</html>
And so, depending on the choice you make, or if you import it into the view, this way (that is, every view will have a require
at the beginning and another at the end):
usuario.php
(view)
<?php require_once(dirname(__FILE__).'/header.php'); ?>
meu conteúdo da view usuário...
<?php require_once(dirname(__FILE__).'/footer.php'); ?>
Or, you can submit the pieces of view together in the control, like this:
usuario.php
(control)
public function minha_funcao() {
// ...
$this->load->view('header', $data);
$this->load->view('usuario', $data);
$this->load->view('footer', $data);
}