Welcome Guest, Not a member yet? Register   Sign In
Redundant data control in Controller, How!!!
#5

[eluser]Derdiusz[/eluser]
You can also add an array variable to your controller:

Code:
class Home extends Controller {
var $data = array();

and in your constructor put your static data:
Code:
function __construct() {
parent::Controller();
$this->data['view_pagetitlebar'] = "Welcome | Muhammad Ahmed";
$this->data['view_metadata'] = "metadata";
$this->data['view_stylesheet'] = "css style sheet";
$this->data['view_navlinks'] = "nav links";
$this->data['view_pagetitle'] = "asd";
        
$this->data['view_contents_left'] = "Left side content";
$this->data['view_footer'] = "Footer";
}

From now load view with:
Code:
$this->load->view('view_main', $this->data);

You able to add (or replace) any data to your $this->data in other methods, like:

Code:
function about() {
$this->data['view_contents_right'] = "This is the about page";
$this->load->view('view_main', $this->data);
}

function home() {
$this->data['view_contents_right'] = "This is the HOME page";
$this->load->view('view_main', $this->data);
}

Greetings
D.


Messages In This Thread
Redundant data control in Controller, How!!! - by El Forum - 08-26-2010, 09:39 AM
Redundant data control in Controller, How!!! - by El Forum - 08-26-2010, 01:07 PM
Redundant data control in Controller, How!!! - by El Forum - 08-27-2010, 03:17 AM
Redundant data control in Controller, How!!! - by El Forum - 08-28-2010, 11:18 AM
Redundant data control in Controller, How!!! - by El Forum - 08-28-2010, 03:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB