How to get site variable in controllers

edited April 2011 in Bug Reports
Hi, can anybody please let me know how to get the value of a site variable in my controller method?

I'm using fuel_var('some_variable_key') but it works only in my view files. In controller it returns nothing. Is there other way how to get the value there?

Thanks.

Comments

  • edited April 2011
    You need to use the Fuel_page class like so:
    $page_init = array('location' => 'contact'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render();
    Where contact is the URI location.
  • edited 12:39PM
    Thanks, I know how to get them to views. But I'd like to use the value in a controller itself (for example e-mail address I'd like the client to be able to change - site variables concept seems perfect for that to me). Any way how to get it there without rendering the page?
  • edited 12:39PM
    You can try using the sitevariables_model directly like so:
    $this->load->module_model(FUEL_FOLDER, 'sitevariables_model'); $email = $this->sitevariables_model->find_one(array('name' => 'email_address'));
Sign In or Register to comment.