How cani pass data from one view to other |
[eluser]evilphp[/eluser]
hi i am new to mvc and currently learning it i want to send data from one page to other in .net i use response.redirect() or set the postback url of the button. but i don't know how to do the same in codeigniter nd i also want to join the data of two views and display it on other view.please guide me. Thank you
[eluser]Nalorin[/eluser]
I'm not sure what exactly you're trying to get at, exactly, but with MVC, all the data is prepared before the view is loaded. The controller takes the input from the user (either via the URL, or via post data in a form), and performs the domain logic to load the proper views and insert the data into the views like so: Code: $data['favorite_movie'] = 'Ghostbusters'; You can also load views from within a view. I use this method on my site, following the pattern on Jeffrey Way's tutorial on http://net.tutsplus.com. Here's a brief summary of how to do that: application/controllers/site.php: Code: class Site extends Controller application/views/includes/template.php Code: <?php And then you can use your imagination on what to do with calendar.php, {$content}.php and includes/static_data.php, but they would be located in the views folder (with static_data.php being in the includes folder therein). Just remember that passing data to a view is easiest (I don't know if it's possible otherwise) if you pass it as an associative array, because the array keys become the variable names inside the called view. So: Code: $data['my_key_name'] = 'my_value'; Code: <?php echo $my_key_name; ?>
|
Welcome Guest, Not a member yet? Register Sign In |