Welcome Guest, Not a member yet? Register   Sign In
show error when working with templates
#1

[eluser]mvn1990[/eluser]
hi, in my project i work with a main tempalte so i have the footer and header in an other view but now i wanne show errors when the user try uploading a file but how can i set the variable for error "empty" when loading the view for example...

array('error' => ' ' );

$data['main_content'] = 'index';
$this->load->view('includes/template', $data);


and also what to do when i wanne show the errors...

$error = array('error' => $this->upload->display_errors());

$data['main_content'] = 'index';
$this->load->view('includes/template', $data);

so how can i pass the variables at the same time with the data and what do i have to write in the view...
thanks in advance
#2

[eluser]bubbafoley[/eluser]
Is this what you are trying to do?

Controller without errors:
Code:
$data = array(
    'error' => '',
    'main_content' => 'index'
);
$this->load->view('includes/template', $data);

Controller with errors:
Code:
$data = array(
    'error' => $this->upload->display_errors(),
    'main_content' => 'index'
);
$this->load->view('includes/template', $data);

View:
Code:
<!-- HEADER CONTENT -->
<?php

if( ! empty($error))
{
    echo $error;
}

?>
<!-- REST OF CONTENT -->
#3

[eluser]mvn1990[/eluser]
awesome, it works...

it safe me a lot of time, thanks




Theme © iAndrew 2016 - Forum software by © MyBB