• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to included a file with in controller

#1
[eluser]sheolikar[/eluser]
Hello sir,

i m using common columnleft.php for all .Inside column left there is database
connection retrieving data.but since there is no columleft in controller.Only in
page it is showing correctly.remaining page it is giving error.help will be
appreciated.
thanks

this is code of home page


$this->load->model('excute');
$data['login'] = $this->excute->loginname($username);
$this->load->view('header',$data);
$this->load->view('contentleft');
$this->load->view('home',$data);
$this->load->view('footer');


now if i am passing result is showing in particular page ie . in home page
only.other page that is client details .it is showing error.
Hi
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: login

Filename: views/contentleft.php

Line Number: 3
help will be appreciated

#2
[eluser]TheFuzzy0ne[/eluser]
REPOST:

Hello sir,

I'm using common columnleft.php for all. Inside column left there is database connection retrieving data.but since there is no columleft in controller. Only in page it is showing correctly. Remaining page it is giving error. Help will be appreciated.

Thanks.

This is code of home page:
Code:
$this->load->model(‘excute’);
$data[‘login’] = $this->excute->loginname($username);
$this->load->view(‘header’,$data);      
$this->load->view(‘contentleft’);
$this->load->view(‘home’,$data);
$this->load->view(‘footer’);

Now if I am passing result is showing in particular page ie. in home page only.other page that is client details. it is showing error.

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: login

Filename: views/contentleft.php

Line Number: 3

Help will be appreciated.

#3
[eluser]TheFuzzy0ne[/eluser]
You could pass the data array in to the view loader:
Code:
$this->load->view('contentleft', $data);

...or you can load the $data array into the view scope with $this->load->vars().
Code:
$data['login'] = $this->excute->loginname($username);
$this->load->vars($data);
$this->load->view('header');
$this->load->view('contentleft');
$this->load->view('home');
$this->load->view('footer');

The latter being the most efficient method to use.

#4
[eluser]sheolikar[/eluser]
sir ,

answer i got from yesterday is not one i m expecting.may be i could not explain in
better way.i will try again.what i mean is that.

consider database query is there inside header or footer.and in controller page
we are using it as in this way.

$this->load->vars($data);
$this->load->view('header');
$this->load->view('contentleft');
$this->load->view('home');
$this->load->view('footer');

now there is no header.php or footer.php in controller.it display result in onlyone
i.e if in home page we are declared above code.it shows database results inhomepage
only.in other pages like client details where to we are using header and footer.it
display error.

so i tried to create header.php in controller side and written sql query there.
but when i tried to include that header.php .it gives error.
any solution.

#5
[eluser]TheFuzzy0ne[/eluser]
You can create a helper or something similar, to load all of the global variables that you need for every single request.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.