2

I am Following this link converting-html-template-to-codeigniter, but Some how it cant able to run header file. here Is my code

<?php    
$this->load->view($this->config->item('bootsshop_template_dir_public') . 'header');
$this->load->view($this->config->item('bootsshop_template_dir_public') . 'content');
$this->load->view($this->config->item('bootsshop_template_dir_public') . 'footer');

can some one help me ... Thanx

Here is my error window enter image description here

Dave
  • 3,073
  • 7
  • 20
  • 33
Muhammad wajih
  • 53
  • 1
  • 10

3 Answers3

0

You can load view file with file name only.No need to load full path. like.. $this->load->view('header');

niral
  • 61
  • 1
  • 1
0

Well for this work i have some best method which call layouts

Number 1 : go to your views folder and create a new folder see the bellow image

enter image description here

Number 2 : add new php file name it layout.php and add this code in the layout.php file

<?php
$this->load->view('common/header');
$this->load->view($view_page);
$this->load->view('common/footer');

Note : the common is my folder name which is located in views folder

Number 3 : Now add the custom controller file inside core folder see in the image

enter image description here

And add the following code in this file

<?php
class MY_Controller extends CI_Controller 
{
   protected $data;
   function __construct() {
       parent::__construct();
   }

   /*  Load the front end layout and set the ouput */
   public function render($layout)
   {
       $this->load->view('layouts/'.$layout, $this->data);
   }
}

Number 4 : Go to your controller file and extends your controller with this file see in the image

enter image description here

Now you able to load your views and pass data to views by the following code

public function index(){
    $this->data['view_page'] = 'index';
    $this->render('layout');
}

You can send data with method see the following function.

public function index(){
    $this->data['pass_your_data_var_here'] = $data;
    $this->data['view_page'] = 'index';
    $this->render('layout');
}
Yaseen Ahmad
  • 1,807
  • 5
  • 25
  • 43
0

I've been working for this too and search a lot, but I can't see any solution. I tried this fix the problem my self and I figured out the code. here's what I do in layout.php I change

bootsshop_template_dir_public

into

ci_my_admin_template_dir_public

here is the whole code:

$this->load->view($this->config->item('ci_my_admin_template_dir_public') . 'header');
$this->load->view($this->config->item('ci_my_admin_template_dir_public') . 'content');
$this->load->view($this->config->item('ci_my_admin_template_dir_public') . 'footer');

Hope this will help you and other that facing the same problem with kode-blog admin panel tutorial.