Reputation: 1219
I am attempting to do some theme structure in my CMS, where you can select a theme for the front end website. This below is part of my code that happens as a certain theme is activated the idea is that it's meant to copy a file from the themes directory (in some form of upload directory) into the views folder in the application folder > views in codeigniter. This isn't really codeigniter specific but i'm still looking to copy my files and replace the existing theme files AND put the file there even if it doesn't exist.
$this->data['main_url'] = FCPATH . 'assets/themes' . $name;
foreach(glob($this->data['main_url'] . '/*.php') as $file) {
if (file_exists($file)) {
if (basename($file) == '_main_layout.php' || basename($file) == '_login_layout.php' || basename($file) == '_register_layout.php') {
copy($file, APPPATH . 'views/' . basename($file));
} else {
$this->data['errors'][] = 'Please note you have included an invalid file. Valid files in the MAIN directory are: _main_layout.php, _login_layout.php and _register_layout.php. Please see the documentation for more information.';
}
}
}
Does anybody know what i am doing wrong here? Thank you.
EDIT: I'm getting no errors and the files aren't copying over the existing files nor copying and adding the new files
Upvotes: 1
Views: 2399
Reputation: 1397
You main_url path incorrect, correct path should be:
$this->data['main_url'] = FCPATH . 'assets/themes/' . $name;
Upvotes: 1