Welcome Guest, Not a member yet? Register   Sign In
Call Controller from View
#11

[eluser]Amit Patel[/eluser]
Thanks for lots of discussion.

Now i want to know is it ok to call other view files in some place of other view file... means suppose i have one view file which is loaded from the controller test.php and in test.php some place i have to write lot many html code so i make other view file called intermidiate.php and now i include that file in some place in test.php...

so this is right way or i have to work in some other way..
#12

[eluser]Colin Williams[/eluser]
Amit, your code will be cleaner if you let the controller provide the content of intermediate.php in a variable.

Code:
$vars['intermediate'] = $this->load->view('intermediate', '', TRUE);
$this->load->vars($vars);

// $intermediate is now available to all views
$this->load->view('test');
#13

[eluser]Amit Patel[/eluser]
Thanks for reply ,

Now if i want to call one controller function in other controller then what is the right way to call it.
#14

[eluser]jedd[/eluser]
[quote author="Amit Patel" date="1237651924"]
Now if i want to call one controller function in other controller then what is the right way to call it.[/quote]

Relocate that code block into an external unit - a library or a helper, say - and each controller can load, and use, it from there.




Theme © iAndrew 2016 - Forum software by © MyBB