• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter with boilerplate

#1
[eluser]maru[/eluser]
Hi everyone!

I was trying to integrate codeigiter and grocery and boilerplate.

I created an controller home

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

class Home extends CI_Controller {
function __construct()
{
  parent::__construct();
}
function index()
{
  $data =  array('title' => 'homepage', 'main_content' => 'home_v');
  $this->load->view('template', $data);
}
}

then I created a folder "includes" with 2 files: header and footer (in views)
and also in views my template and a file home_v with some text just to know if my example was working.

template.php

Code:
<!DOCTYPE html>
&lt;!--[if lt IE 7]>         &lt;html class="no-js lt-ie9 lt-ie8 lt-ie7"&gt; <![endif]--&gt;
&lt;!--[if IE 7]>           &lt;html class="no-js lt-ie9 lt-ie8"&gt; <![endif]--&gt;
&lt;!--[if IE 8]>           &lt;html class="no-js lt-ie9"&gt; <![endif]--&gt;
&lt;!--[if gt IE 8]>&lt;!--&gt; &lt;html class="no-js"&gt; &lt;!--<![endif]--&gt;
        &lt;head&gt;
                &lt;meta charset="utf-8"&gt;
                &lt;meta http-equiv="X-UA-Compatible" c&gt;
                &lt;title&gt;$title&lt;/title&gt;
                &lt;meta name="description" c&gt;
                &lt;meta name="viewport" c&gt;
                &lt;!-- Place favicon.ico and apple-touch-icon.png in the root directory --&gt;
                &lt;link rel="stylesheet" href="&lt;?php echo base_url('css/normalize.css'); ?&gt;"&gt;
                &lt;link rel="stylesheet" href="&lt;?php echo base_url('css/main.css'); ?&gt;"&gt;
                [removed][removed]
        &lt;/head&gt;
        &lt;body&gt;
                &lt;!--[if lt IE 7]>
                        <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
                <![endif]--&gt;
                &lt;!-- Add your site or application content here --&gt;
                <div id="container">
                &lt;header&gt;
                 &lt;?php $this->load->view('includes/header'); ?&gt;
                        &lt;?php $this->load->view('includes/menu'); ?&gt;
                &lt;/header&gt;
          
                <div id="main" role="main">
                 &lt;?php $this->load->view($main_content); ?&gt;
                </div>
          

                <footer>
                 &lt;?php $this->load->view('includes/footer'); ?&gt;
                </footer>
                </div>
                &lt;!-- fin container --&gt;
          
                [removed][removed]
                [removed]window.jQuery || [removed]('[removed]<\/script>')[removed]
                [removed][removed]
                [removed][removed]
                &lt;!-- Google Analytics: change UA-XXXXX-X to be your site's ID. --&gt;
                [removed]
                        var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
                        (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
                        g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
                        s[removed].insertBefore(g,s)}(document,'script'));
                [removed]
        &lt;/body&gt;
&lt;/html&gt;


After that a new controller categorias

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


class Categorias extends CI_Controller {

function __construct()
{

parent::__construct();

$this->load->database();

$this->load->library('grocery_crud');

$this->load->helper('url');
}

function index()
{

$data = array('css_files' => array('main.css'));
$this->load->view('categorias/categorias_v', $data);

$data = array('title' => 'categorias', 'main_content' => 'categorias/categorias_v');
$this->load->view('template', $data);

}


function categorias_v()
{
try{

$crud = new grocery_CRUD();

$crud->set_theme('flexigrid');

$crud->set_table('categorias');

$crud->set_subject('Categorias');

$crud->set_language('spanish');

$crud->required_fields(
'id_categoria',
'nombre_categoria'
);

$crud->columns(
'id_categoria',
'nombre_categoria'
);

$output = $crud->render();


}catch(Exception $e){

show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
}

but this is not working, I have some errors


A PHP Error was encountered

Severity: Notice
Message: Undefined variable: js_files
Filename: categorias/categorias_v.php
Line Number: 5

A PHP Error was encountered

Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: categorias/categorias_v.php
Line Number: 5

A PHP Error was encountered

Severity: Notice
Message: Undefined variable: output
Filename: categorias/categorias_v.php
Line Number: 9
header menu


A PHP Error was encountered

Severity: Notice
Message: Undefined variable: js_files
Filename: categorias/categorias_v.php
Line Number: 5

A PHP Error was encountered

Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: categorias/categorias_v.php
Line Number: 5

A PHP Error was encountered

Severity: Notice
Message: Undefined variable: output
Filename: categorias/categorias_v.php
Line Number: 9


Maybe someone have a different idea, I just want a header and footer and just change the main content to avoid copy paste the same code in every crud.

Thanks in advance! Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.