Welcome Guest, Not a member yet? Register   Sign In
File checking
#1

In my view folder I have a theme_view.php

Which checks for multiple views etc and sets the correct theme.

Is this code OK seems to work

PHP Code:
<?php 

$views 
= array(
    
APPPATH 'views/theme/' $this->config->item('config_theme') . '/template/common/header_view.php',
    
APPPATH 'views/theme/' $this->config->item('config_theme') . '/template/' $page '.php',
    
APPPATH 'views/theme/' $this->config->item('config_theme') . '/template/common/footer_view.php',
);

foreach (
$views as $view) {

    if (
file_exists($view)) {
        
$output $view;
        break;
    }
}

if (
$output == TRUE) {
    
    
$this->load->view($this->config->item('config_theme') . '/template/common/header_view');
    
$this->load->view($this->config->item('config_theme') . '/template/' $page);
    
$this->load->view($this->config->item('config_theme') . '/template/common/footer_view');

} else {
    
    
show_error('Your Views ' $view 'Do Not Exists!');
}

?>


And Controller

PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

    public function 
index()
    {
        
$data['title'] = 'Welcome To Codeigniter';

        
$data['page'] = 'common/home_view';

        
$this->load->view('theme_view'$data);
    
    }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
File checking - by wolfgang1983 - 07-01-2016, 02:41 AM
RE: File checking - by PaulD - 07-01-2016, 04:12 AM
RE: File checking - by wolfgang1983 - 07-01-2016, 04:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB