CodeIgniter Forums

Full Version: Calling the View from Function Index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]crispinatari[/eluser]
index.php
Code:
<DIV ID="side_menu">
      &lt;?php $this->load->view('Main/menu');?&gt;
</DIV>
<DIV ID="main_content">
      &lt;?php $this->load->view('empslistview.php');?&gt;
</DIV>

emps controller
Code:
function index()
    {
        //default method, gets data from model
        //and lists all employees using default view
        
        
      $data['title'] = "Employee application";
        $data['heading'] = "Employee List";
        
          /// LOADING PARTIALS //
        $data ['header']     = $this->load->view('views/header', $data, TRUE);
        $data ['menu']       = $this->load->view('views/menu', $data, TRUE);
        $data ['footer']     = $this->load->view('views/footer', $data, TRUE);  
        
      $data['res']=$this->empsmodel->get_all_emps();
      $this->load->view('empslistview', $data);
      }

this produces error:
"Fatal error: Using $this when not in object context in W:\www\CI1\index.php on line 5"


am i calling the view incorrectly in the index page? :0(

El Forum

[eluser]jedd[/eluser]
Yes.

You shouldn't be fiddling with the index.php file.

At all.

Ever.

Really truly.

El Forum

[eluser]TheFuzzy0ne[/eluser]
I'm a bit lost. Where does index.php come into this? Shouldn't it be empslistview.php?

El Forum

[eluser]crispinatari[/eluser]
well considerring index.php is the first page i link to, surely that is where the layout your menu, header, footer, isn't it? so im trying to link four views into the index page which is my main page

El Forum

[eluser]TheFuzzy0ne[/eluser]
Please see my [url="http://ellislab.com/forums/viewthread/107773/"]CodeIgniter Resources thread[/url] that should help set you in the right direction.

El Forum

[eluser]jedd[/eluser]
[quote author="crispinatari" date="1244831842"]well considerring index.php is the first page i link to, surely that is where the layout your menu, header, footer, isn't it? so im trying to link four views into the index page which is my main page[/quote]

Where is this index.php that is the first page you link to? Is it the one that came with the install of CI, or is it one that you've created somewhere in a controller or view directory?

If the former, I refer you to the previous words of someone who's actually smarter than they appear:

[quote author="jedd" date="1244831686"]Yes.

You shouldn't be fiddling with the index.php file.

At all.

Ever.

Really truly.[/quote]

If the latter, cut it out, and use other, more meaningful words as your controller names. It'll be far less confusing (for both of us).

El Forum

[eluser]Dam1an[/eluser]
[quote author="jedd" date="1244837951"]If the former, I refer you to the previous words of someone who's actually smarter than they appear:
[quote author="jedd" date="1244831686"]
You shouldn't be fiddling with the index.php file.

At all.

Ever.

Really truly.[/quote][/quote]

You forgot to include modest Wink

El Forum

[eluser]wiredesignz[/eluser]
@Jedd, You can't say you are smarter than you appear because we don't know what you look like. Tongue