Welcome Guest, Not a member yet? Register   Sign In
Dynamic variable easy implementation
#4

[eluser]JoostV[/eluser]
If you mean that you don't want to have to edit every $this->load->view() call, that's not a problem. You have access to $this in your views as well. So you can do:
Code:
echo $this->data['tokens'];

It's ugly, but it works Wink

If it's the fetching of the 'tokens' that's the problem: well, I'm not sure what parameters you need to fetch these 'tokens' form the database. But if you have access to them in MY_Controller, you can fetch it from the database there and you do not have to set it anywhere else. It will always be available in any controller that extends MY_Controller.

For instance, if you need the controller name and method to retrieve tokens form the database, you could do sth. like this in MY_Controller.

Code:
$controller = $this->router->fetch_class();
$method = $this->router->fetch_method();
$this->load->model('tokens_m');
$this->data['tokens'] = $this->tokens_m->get($controller, $method);



Messages In This Thread
Dynamic variable easy implementation - by El Forum - 01-15-2013, 09:13 AM
Dynamic variable easy implementation - by El Forum - 01-15-2013, 09:56 AM
Dynamic variable easy implementation - by El Forum - 01-16-2013, 01:28 AM
Dynamic variable easy implementation - by El Forum - 01-16-2013, 01:48 AM
Dynamic variable easy implementation - by El Forum - 01-16-2013, 02:03 AM
Dynamic variable easy implementation - by El Forum - 01-16-2013, 02:18 AM
Dynamic variable easy implementation - by El Forum - 01-16-2013, 02:20 AM
Dynamic variable easy implementation - by El Forum - 01-16-2013, 01:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB