Welcome Guest, Not a member yet? Register   Sign In
Error loading an template view
#1

[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...ravlh.png/


Thanks!
#2

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

[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); ?>
#4

[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
#5

[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?




Theme © iAndrew 2016 - Forum software by © MyBB