Jump to content


Using Custom Template

template theme

  • Please log in to reply
2 replies to this topic

#1 h4kl0rd

h4kl0rd

    Newbie

  • Members
  • Pip
  • 8 posts
  • LocationDar es salaam, Tanzania

Posted 05 October 2013 - 10:19 AM

I'm using the latest Grocery CRUD (version 1.4.1).

I want to integrate a custom template and I have configured my files as follows:

 

I created an includes directory in views, which contains the following files:

  • header.php - contains header files like js,css...
  • footer.php - contains footer files
  • template.php - loads header, content and footer

My template.php looks like this:

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

This is how I call them from the controller:

public function index()
{
     $data['content'] = 'index';
     $this->load->view('includes/template', $data);
}

After using Grocery CRUD, my controller looks like this:

class Users extends CI_Controller {

    public function __construct() 
    {
        parent::__construct();

        $this->load->library('grocery_CRUD');
    }

    public function output($output = null)
    {
        $this->load->view('output_view',$output);
    }

    public function index()
    {
        $this->output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
    }

    public function view()
    {
        try {
            $crud = new grocery_CRUD();

            $crud->set_theme('twitter-bootstrap');
            $crud->set_table('users');

            $crud->...

            $output = $crud->render();
            $this->output($output);            

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

I went through one of the threads (Template controller to grocery CRUD). It didn't seem to work.

How do I integrate my custom template with Grocery CRUD?

 

 



#2 h4kl0rd

h4kl0rd

    Newbie

  • Members
  • Pip
  • 8 posts
  • LocationDar es salaam, Tanzania

Posted 10 October 2013 - 09:19 AM

At last I succeeded in integrating my custom template with Grocery Crud.

 

Here's my implementation:

 

I created a universal view that works for all my output: views >> out.php

In the head of my file, I added the grocery_crud styles and scripts:

<?php 
    foreach($css_files as $file): ?>
      <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
    <?php endforeach; ?>
    <?php foreach($js_files as $file): ?>
      <script src="<?php echo $file; ?>"></script>
    <?php endforeach; ?>

 

In my Controller, I made the following modifications:

try {
      $crud = new grocery_CRUD();

      $crud->set_theme(...);
      $crud->set_table(...);

      $crud->....

      $output = $crud->render();

      // comment or remove the default grocery_crud output
      //$this->output($output);

      // load your custom view
      $this->load->view('out', $output);
            
 } catch(Exception $e){
      show_error($e->getMessage().' --- '.$e->getTraceAsString());
 }


#3 IDe

IDe

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 17 April 2015 - 01:49 PM

 

At last I succeeded in integrating my custom template with Grocery Crud.

 

Here's my implementation:

 

I created a universal view that works for all my output: views >> out.php

In the head of my file, I added the grocery_crud styles and scripts:

<?php 
    foreach($css_files as $file): ?>
      <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
    <?php endforeach; ?>
    <?php foreach($js_files as $file): ?>
      <script src="<?php echo $file; ?>"></script>
    <?php endforeach; ?>

 

In my Controller, I made the following modifications:

try {
      $crud = new grocery_CRUD();

      $crud->set_theme(...);
      $crud->set_table(...);

      $crud->....

      $output = $crud->render();

      // comment or remove the default grocery_crud output
      //$this->output($output);

      // load your custom view
      $this->load->view('out', $output);
            
 } catch(Exception $e){
      show_error($e->getMessage().' --- '.$e->getTraceAsString());

I tried this implementation ,, no way ,, I cant load my template with GC







Also tagged with one or more of these keywords: template, theme

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users