• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to call function from Controller to include into the View page with Codeigniter?

#1
[eluser]Unknown[/eluser]
I want to call function from Controller to include into the View page with Codeigniter. Usually when I open any page, I call $this->load->view() in Controller for open that page. Now I want to include sub page into main page, but it can't include any function in View. I try to include function like this.

Code:
<body><? include(site_url().'/login'); ?></body>
    <body><? include('/login'); ?></body>
    <body><? include('./login'); ?></body>

I can open page with this link http://localhost/ci_house/index.php/login. but when I open main page for run my code it show these error.

Quote: A PHP Error was encountered

Severity: Warning

Message: include(http://localhost/ci_house/index.php/login) [function.include]: failed to open stream: no suitable wrapper could be found

Filename: views/main.php

Line Number: 8
A PHP Error was encountered

Severity: Warning

Message: include() [function.include]: Failed opening 'http://localhost/ci_house/index.php/login' for inclusion (include_path='.;C:\\php5\\pear')

Filename: views/main.php

Line Number: 8


I want to show 2 view in 1 page .
Code:
function test1()
    { $data['var_for_login_view'] = 'get table1';
      $this->load->view('main1',$data);
    }
    function test2()
    { $data['var_for_login_view'] = 'get table2';
      $this->load->view('main2',$data);
    }

In views/main.php:
Code:
$this->load->view('test1');
    $this->load->view('test2');`

I want to show like
Code:
<body>
    include('main1.php');
    include('main2.php');
    </body>
but I can show like this in Codeigniter.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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