⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠


profile picture

Adding custom config variables


  • profile picture
  • Member

Posted 18 July 2014 - 11:33 AM

I've been doing a bit more hacking of the core GC code, this time to allow the flexigrid actions to display on the left of the screen - and that in turn needed an extra config variable in application/config/grocery_crud.php


That in turn needed a mod to application/libraries/Grocery_CRUD.php to load the new variable into the actual GC config - which is where I saw you are missing a trick.


Look for the function called "_initialize_variables()" around line 4389 and proceed as follows:


1. Comment out or remove all of the lines like $this->config->default_language = $ci->config->item('grocery_crud_default_language');


2. Add this code to replace the individual setting of the config variables:


foreach ($ci->config->config as $property => $value) {
    if (substr($property, 0, 13) == 'grocery_crud_') {
        $prop = substr($property, 13);// remove leading grocery_crud_ from property name
        $this->config->$prop = $value;
Now all you need to do is declare a config variable (remember the "grocery_crud_" prefix) in application/config/grocery_crud.php and the property will automatically be added to your GC configuration.