CodeIgniter Forums
How calling function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How calling function (/showthread.php?tid=3756)



How calling function - El Forum - 10-20-2007

[eluser]iniweb[/eluser]
Example:

News.php
Code:
<?php

class News extends Controller {

    function News()
    {
        parent::Controller();    
    }
    
    function Index()
    {
        $content = '';

        $content .= $this->uri->segment('1');

        $data = array(
                       'content'  => $content,
                 );

        $this->parser->parse('Empty.tpl', $data);
    }
}

?>

Code:
<?php

class Main extends Controller {

    function Main()
    {
        parent::Controller();    
    }

    function Func()
    {
        $content = "";

        $data = array(
                       'content'    => $this->News_block(),
                       'cat_block'  => $this->Cat_block(),
                                 );

        $this->load->library('parser');
        $this->parser->parse('Main.tpl', $data);
    }
}

?>

How on News class call Func() function !?


How calling function - El Forum - 10-20-2007

[eluser]unosoft[/eluser]
You cannot call a function in one controller from another controller. Instead, you need to move the Func() function to a Library and load the library in both the controllers.

hth
Kumar Bhogaraju