![]() |
Help: How i show variables from different functions on the same view? - 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: Help: How i show variables from different functions on the same view? (/showthread.php?tid=25015) |
Help: How i show variables from different functions on the same view? - El Forum - 11-27-2009 [eluser]Unknown[/eluser] How i show variables from different function on the same view? I have variables in different functions and i wanna show them in only one view ... how can i do that? Thanks in advance Help: How i show variables from different functions on the same view? - El Forum - 11-27-2009 [eluser]Aken[/eluser] Can you be more specific? Any variables you want to pass through to a view should be defined in an array, and passed as the second parameter when loading a view. Help: How i show variables from different functions on the same view? - El Forum - 11-27-2009 [eluser]Unknown[/eluser] Code: class site extends Controller { Help: How i show variables from different functions on the same view? - El Forum - 11-27-2009 [eluser]jedd[/eluser] You could do it this way: Code: class Site extends Controller { // Fixed case of class name Note that menu_name does exist in both functions, but has a different value in both functions, so I'm not sure how you can cut down on the number of times you define that variable. You might also want to hit the [url="/wiki/FAQ"]FAQ[/url], hit the commonly asked question 'I'm repeating lots of bits of code, is there anyway around that?' and then follow the link to my rant. Also accessible from the [url="/wiki"]main wiki[/url] front page if you follow the Approaches yellow brick path. It sounds like what you're trying to do is covered, at least in part, by that. |