CodeIgniter Forums
method call to other methods - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: method call to other methods (/showthread.php?tid=35557)



method call to other methods - El Forum - 11-03-2010

[eluser]atoleon[/eluser]
I have a controller wich there are some method wich do different tasks but all of them load the same view.
Is posible that only one method load the view and the others method call to this method when it finish the task and load the view?


method call to other methods - El Forum - 11-03-2010

[eluser]SPeed_FANat1c[/eluser]
I don't understand the question.

Code:
function f1()
{
  $this->load->view('v');
}

function f2()
{
  $this->load->view('v');
}

function f3()
{
  $this->load->view('v');
}

"Is posible that only one method load the view"

Yeah, it is possible if you add some checking before loading view -
Code:
if($I_want_load)
    $this->load->view('v');


But what do you want to say with this "and the others method call to this method when it finish the task and load the view?" ?


method call to other methods - El Forum - 11-03-2010

[eluser]atoleon[/eluser]
Can i make this:
[quote author="SPeed_FANat1c" date="1288800646"]I don't understand the question.

Code:
function f1()
{
  $this->load->view('v');
}

function f2()
{
  //$this->load->view('v');
  f1(); //to load view ('v')
}

function f3()
{
  //$this->load->view('v');
  f1(); //to load view ('v');
}

"Is posible that only one method load the view"

Yeah, it is possible if you add some checking before loading view -
Code:
if($I_want_load)
    $this->load->view('v');


But what do you want to say with this "and the others method call to this method when it finish the task and load the view?" ?[/quote]


method call to other methods - El Forum - 11-03-2010

[eluser]smilie[/eluser]
Hi,

Yes, it is possible.

Code:
function loadPage($param)
{
    $this->load->view('v',$param);
}

function shoes()
{
   # some coding happens here...
   # Coding done, load page
   $param = ...
   $this->loadPage($param);
}

function house()
{
   # Again, some coding here...
   $param = ...
   $this->loadPage($param);
}

In above code, I have added passing variables to loadPage() function, as I presume you may need them :-)

Cheers,
Smilie


method call to other methods - El Forum - 11-03-2010

[eluser]atoleon[/eluser]
Thankyou very much. It will be useful for my me.