Multiple views sharing variables "upwards" |
[eluser]GregX999[/eluser]
Sorry for the strange subject... I'm using a pretty basic, home-brewed template system. Basically, my controller methods call a "render" function that calls a layout view, then the layout view then calls the "content view". I'd like to know if there's a way for a variable set in the content view to be used by the layout view. Perhaps it's more clear with examples: A method from a controller: Code: function about() The render function (in a custom library, view.php): Code: function render($data, $view, $layout='main') The "main" layout (as opposed to the "popup" layout or any other layout that the site may use): Code: <html> And the "about" view: Code: <div id="toffees"> So... my main question: How can I move page_title and extra_css from the "about" method in the controller into the "about" view? So that my "about" view would look like this: Code: <? $data['page_title'] = 'About Our Wonderful Stuff'; ?> Is it possible? Greg
[eluser]Isern Palaus[/eluser]
[quote author="GregX999" date="1259879572"] $data['CI'] =& $this->CI; // Passed through so that the layout file can call "load->view" in order to load the view.[/quote] You can use $this->load->view() like if you're inside the controller. Check it!
[eluser]GregX999[/eluser]
[quote author="Isern Palaus" date="1259909143"]You can use $this->load->view() like if you're inside the controller. Check it![/quote] Oh, ok, that worked. So I don't need to use that $CI variable. But, that still doesn't allow variables to be passed "backwards" does it?
[eluser]raitucarp[/eluser]
I have solution, maybe you want to use my library http://raitzine.com/codeigniter-theme-library.html |
Welcome Guest, Not a member yet? Register Sign In |