WOrking with custom config files |
[eluser]xtremer360[/eluser]
I'm trying to figure out why this won't work. I created my own custom config file and autoloaded it and for some reason isn't getting the value of the config index I'm looking for. I'm getting an error message that says: Unable to load the requested file: template//cpanel/index.php So if you notice its missing a value in between two slashes. Code: $config['defaultTemplate'] = 'peach'; Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[eluser]Aken[/eluser]
To see if the config file is loading, put something like this in it: Code: exit('file loaded'); If you receive that message, then the file is being loaded but the value is changing somewhere. If it does not show, then your file isn't being loaded. If that doesn't help you figure out the problem, post your config file contents, make sure you're autoloading properly, and double check that the variable isn't being overwritten by another config item with the same name (yes, naming conflicts are a common problem).
[eluser]weboap[/eluser]
i second @Aken shortcut to find if naming conflict test by putting Code: $config['defaultTemplate'] = 'peach'; in config.php, if it works then it's just the autoload broke somewhere.
[eluser]xtremer360[/eluser]
Yes I put that inside of config.php and it worked so why woudl it be that its not getting that in the myconfig file. Autoload: $autoload['config'] = array('myconfig');
[eluser]Samus[/eluser]
this "template//cpanel/index.php" makes it look like you didn't specify the config file properly. post your auto load code here
[eluser]weboap[/eluser]
@xtremer360 you made me doubt my self hehehe. created a setup.php config file putted it in application/config/setup.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); in application/config/autoload.php Code: $autoload['config'] = array('setup'); then in the welcome controller Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); output : peach it worked. so either your not autoloading, do to some modification in the lib, or the file is not in the right place or misspelling of the config file name..... or the index defaultTemplate is used somewhere with and empty value, set after your autoload. (try to load manually the config right before the line where you need it : $this->config->load('filename'); then if needed change the index to something else ....) .....
[eluser]xtremer360[/eluser]
Its weird because i changed the file name to config1 and changed it to that in the autolaod and then it worked so i just find it odd.
[eluser]xtremer360[/eluser]
However I want to do an if statement inside the config file so that if that directory doesn't exist then it defaults to a certain one. So how woudl I check to see if a template exists. Code: if () {
[eluser]weboap[/eluser]
i will use rather a MY_Controller and extend all the controllers to it, and run in the construct functions that will load the template stuff. read the config, load the template file and that's where i will check if the directory, or the file of the template exist http://ellislab.com/codeigniter/user-gui...elper.html http://php.net/manual/en/function.file-exists.php |
Welcome Guest, Not a member yet? Register Sign In |