Welcome Guest, Not a member yet? Register   Sign In
How to add sidebar?
#3

[eluser]Mushex Antaranian[/eluser]
As I understand, you want to put sidebar in every page (or many pages) of your site and call it only once. Try to use this structure

Your views folder structure

views/index.php
views/header.php
views/footer.php
views/sidebar.php
views/some_page.php


where index.php is your master view and looks like this

Code:
<?php
//master view - index.php
$this->load->view('header');
$this->load->view($page);
$this->load->view('sidebar');
$this->load->view('footer')
?>

.. and your controller will look like this

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Some_controller extends Controller {
    
    function Some_controller()
    {  
    parent::Controller();
    }
    
    function index()
    {
        //put here view name you want load as main page
        $page = 'some_page';
        //put here any data to send to view
        $data['page'] = $page;
        //this will load your master view
        $this->load->view("bes/index", $data);
    }

}
/* End of file some_controller.php */
/* Location: ./your/controller/path/some_controller.php */

Wish it will help you Smile


Messages In This Thread
How to add sidebar? - by El Forum - 04-03-2009, 07:08 PM
How to add sidebar? - by El Forum - 04-03-2009, 08:28 PM
How to add sidebar? - by El Forum - 04-04-2009, 12:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB