CodeIgniter Forums
Error loading an template view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Error loading an template view (/thread-54142.html)



Error loading an template view - El Forum - 08-24-2012

[eluser]Diegosf93[/eluser]
I have this problem when i try to load an template view with another view, lets see the code:

This is the code of the template:

Code:
<?php $this->load->view('header.php'); ?>

<?php $this->load->view($contenido); ?>

<?php $this->load->view('footer.php'); ?>

Then in the controller i have this:
Quote:Here I load a droplist with categories and i pass it to the "Agregar_Operador" view in a variable.
And then load the template with the ยท$data array inside the "Agregar_Operador" view to the template.

Code:
$datas['categorias']=$this->Admin_Model->Cargar_Categorias();    
$data['contenido']=$this->load->view('Panel_Admin/Agregar_Operador', $datas,true);
$this->load->view('template',$data);

This appear me in the browser:
http://imageshack.us/photo/my-images/402/capturavlh.png/


Thanks!


Error loading an template view - El Forum - 08-24-2012

[eluser]DarkManX[/eluser]
the view loader need the view name not the view filename - 'header' and 'footer'


Error loading an template view - El Forum - 08-24-2012

[eluser]CroNiX[/eluser]
You've already loaded the view into the $contenido variable in your controller. Just
Code:
echo $contenido;
in your template instead of
Code:
<?php $this->load->view($contenido); ?>



Error loading an template view - El Forum - 08-24-2012

[eluser]vitoco[/eluser]
When you load a view, the first parameter it's the filename of the view
Code:
<?php $this->load->view('header.php'); ?>

<?php $this->load->view($contenido); ?>

<?php $this->load->view('footer.php'); ?>


But here

Code:
$data['contenido']=$this->load->view('Panel_Admin/Agregar_Operador', $datas,true);

you're storing in ['contenido'] the returned html from the view 'Panel_Admin/Agregar_Operador', not the view filename. so change it to this.

Code:
<?php $this->load->view('header.php'); ?>

<?php echo $contenido; ?>

<?php $this->load->view('footer.php'); ?>


Slds



Error loading an template view - El Forum - 08-24-2012

[eluser]Diegosf93[/eluser]
Thanks very much for the answers, I solved the problem!

I edit this:

I have this other problem i have in another controller this code:

Code:
function index()
{

$data['contenido']='Login_Registro/formulario_login';
$this->load->view('template',$data);

}

I need to save the view "formulario_login" in a variable to pass it to the template view like i do before?