Welcome Guest, Not a member yet? Register   Sign In
Variable data in static views
#2

[eluser]nelson.wells[/eluser]
You could write a custom controller that inherits from the base controller, load the variables in that controller's constructor, and then have all of your other controllers inherit from that constructor. Something like this (written in the browser, so untested.):

Code:
class MY_Controller extends CI_Controller
{
     function __construct()
     {
         //global variables
         $data["my_header_view_DATA"] = "Tralala";
         $data["my_right_column_view_DATA"] = "--&gt;Something that i'm bringing from my database<--";    

         $this->load->vars($data);
     }
}

Code:
class Welcome extends MY_Controller
    {
         //your normal controller methods
    }

Any controller that extends MY_Controller will have access to $my_header_view_DATA in the view it loads. Like I said, it is untested so it may have typos, but the idea is there. Hope that helps.


Messages In This Thread
Variable data in static views - by El Forum - 03-23-2010, 11:07 AM
Variable data in static views - by El Forum - 03-23-2010, 11:17 AM
Variable data in static views - by El Forum - 03-23-2010, 11:21 AM
Variable data in static views - by El Forum - 03-23-2010, 11:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB