How to make a sliced layout using the codeigniter framework?

0

I'm trying to create a basic% system with CRUD , where the page header and footer are fixed and dynamic content, but I have no idea how to do this. Can anyone help me?

    
asked by anonymous 17.02.2015 / 18:21

1 answer

1

create a view as index

view_index.php

<?php 
$this->load->view('includes/header');//INCLUI A VIEW DENTRO DA PASTA VIEW/INCLUDE/HEADER.PHP
$this->load->view('includes/menu');//INCLUI A VIEW DENTRO DA PASTA VIEW/INCLUDE/MENU.PHP
if($tela != '') $this->load->view('telas/'.$tela);//VERIFICA SE FOI PASSADA A VIEW PELO CONTROLLER SE NÃO ELE USA O CONTROLLER INDEX COMO PADRÃO
$this->load->view('includes/footer');//INCLUI A VIEW DENTRO DA PASTA VIEW/INCLUDE/FOOTER.PHP

Then you just pass the data through the controller so it pulls the view according to each function you create and passes the view name to the data variable

crud.php

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

class Crud extends CI_Controller {
    //CONSTRUCTOR
    public function __construct(){
    parent::__construct();//CHAMA O CONSTRUTOR DA CLASSE PAI
    $this->load->helper('url');//CARREGA O HELPER
}

public function index(){
    //$this->load->helper('url'); CARREGA APENAS PARA A FUNÇÃO
    $dados  =   array(
        'titulo'    =>  'Crud com CodeIgniter',
        'tela'      =>  '',
    );
    $this->load->view('crud',$dados);
}

//TELAS
public function create(){
    $dados  =   array(
        'tela'      =>  'nome_da_view'
    );
    $this->load->view('crud',$dados);
}
    
27.02.2015 / 19:47