Welcome Guest, Not a member yet? Register   Sign In
Custom design for grocery crud
#1

I have used grocery crud to generate crud in my project. I have number of crud in my project and for each crud I have different design. Is there any way to achieve different designs for each crud forms. If so please do provide with the steps.
Reply
#2

(This post was last modified: 09-22-2015, 02:24 AM by Muzikant.)

In /assets/grocery_crud/themes/ you can find available themes. You should find there datatables and flexigrid. You can create your own by modifying them. To choose own visual, use set_theme function in your controller.

PHP Code:
$crud = new Grocery_CRUD();
$crud->set_theme('datatables'); // you can use your own theme here
... 
Reply
#3

(09-22-2015, 02:20 AM)Muzikant Wrote: In /assets/grocery_crud/themes/ you can find available themes. You should find there datatables and flexigrid. You can create your own by modifying them. To choose own visual, use set_theme function in your controller.


PHP Code:
$crud = new Grocery_CRUD();
$crud->set_theme('datatables'); // you can use your own theme here
... 

The above method only changes the theme. But I need to have different design for each crud. If I had 30 crud I may need to have 30 themes. I need to change the html of each form. 
Reply
#4

(This post was last modified: 09-22-2015, 10:23 AM by Muzikant.)

Maybe I do not understand, what do you mean by desing. :-(

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

class 
Admin extends CI_Controller {
    public function 
__construct() {
        
parent::__construct();
        
$this->load->library('Grocery_CRUD');
    }
    
    public function 
categories() {
        try {
            
$crud = new Grocery_CRUD();
            
            
$crud->set_table('categories');
            
$crud->set_subject('Categories');
            
$crud->unset_columns('id');
            
$crud->
                
display_as('title''Title')->
                
display_as('desc''Description')->
                
display_as('order''Order');
            
$crud->
                
order_by('order''asc')->
                
order_by('title''asc');
            
            
$crud->field_type('id''readonly');
            
$crud->required_fields('title');
            
$crud->unique_fields('title');
            
$crud->unset_texteditor('desc');
            
            
$crud->set_rules('order''Order''integer');
            
            
$output $crud->render();
            
$this->load->view('admin'$output);
        } catch (
Exception $e) {
            
show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
    }
    
    public function 
pages() {
        try {
            
$crud = new Grocery_CRUD();
            
            
$crud->set_table('pages');
            
$crud->set_subject('Pages');
            
$crud->unset_columns('id');
            
$crud->
                
display_as('title''Title')->
                
display_as('desc''Description')->
                
display_as('text''Text');
            
$crud->
                
order_by('title''asc');
            
            
$crud->field_type('id''readonly');
            
$crud->required_fields('title');
            
$crud->unique_fields('title');
            
$crud->unset_texteditor('desc');
            
            
$output $crud->render();
            
$this->load->view('admin'$output);
        } catch (
Exception $e) {
            
show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
    }


Read the GroceryCrud documentation, especially API and Functions list.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB