⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


How to use image crud and grocery crud to create a portfolio.

image crud grocery crud

  • Please log in to reply
5 replies to this topic

#1 HPM

HPM

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 07 June 2015 - 04:49 PM

Hello! I'm new to this,please help me! I want to add a portfolio to my system(i have attached a image to give a idea about my requirement). I have a table called gallery(table fields are -- gallery_id, client,location, date and image_url) Since image crud is only providing crud functions for images how can i add/edit/update other fields in the gallery table.I have tried image crud earlier.that was so great.but i cant manage to apply image crud according to my requirement.It helped to upload many files at once but what i want is to upload many images according to a category.I saw there is a a method call photo gallery within a category in image crud documentation,but i couldn't apply it correctly.it gave me many errors like missing css and js files.I would like to here a simple explanation to my problem,if anyone can help me to create this portfolio that would be a big help.have a great day :)Fullscreen capture 672015 94023 PM.jpg    



#2 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts

Posted 07 June 2015 - 08:43 PM

Hi! first of all you need write some start code and if any errors you will get - post it here.

 

And looking by pictures that you attached - this view you need write by yourself using simple html and css.

 

Image Crud you will be using on the admin site of your web app



#3 HPM

HPM

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 08 June 2015 - 04:51 AM

Hi !thank you for the solution!yes im asking about the admin functon, i want to add  images to the gallery under a category with some information relating to images(just like in the previously attached photo of a portfolio )to do this  do i need to call both image crud library and grocery crud library at the same time in my gallery controller?since i cant upload many photos at once by using grocery crud i have to call image crud library right?but i need to add information relates to the images too,so what im really asking is the way to connect these two library function in a one controller.i hope you will get what im asking.thanks again for the reply ! :)(i have attached the image crud code and the output of it,i want to add the other information like client and locations to add edit update at the same time with the images.If you cant get what im saying please watch this video ,that is the way i want it   --  

 

 

this is my controller with image crud function

 

Fullscreen capture 682015 100919 AM.jpg

 

 

 

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Gallery extends CI_Controller {
 
public function __construct()
{
parent::__construct();
 
$this->load->database();
 
 
$this->load->library('image_CRUD'); //calling imagae crud library
}
 
 
public function index()
{
 
 
 
public function gallery_output($output = null) 
    {
       
 
        $data['opt'] = $output;
        $this->load->view('show_crud_view', $data);          
    } 
 
 
 
function gallery_management()
   {
    $image_crud = new image_CRUD();
 
    $image_crud->set_table('tbl_gallery');
 
    $image_crud->set_url_field('image_url');
    $image_crud->set_image_path('assets/images/gallery');
 
 
 
  
    $output = $image_crud->render();
 
    $this-> gallery_output($output);
}
 
 
 
 
}
?>


#4 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts

Posted 08 June 2015 - 10:11 AM

Hi, I can give you the main idea. You need create entity like "client" that will contains all info about hotel, location, name and so on.

 

Using function add_action from GC API you can attach Image Crud per one client and   "client_id" will be instead of "catagory_id"

class Clients {

//data that send to output
public $data;

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

public function clients()
{

     $table = 'clients';     

     $this->crud->add_action('Client gallery','','admin/clients/gallery','ui-icon-grip-dotted-vertical');  

      $this->_example_output();
}


    
//gallery per client
public function gallery($client_id) 
{
        $primary_key = $this->uri->segment(4);

        if($primary_key === 'upload_file')
        {
            $primary_key = $this->uri->segment(5);
        }
        
        $upload_path = PROJECTS_UPLOAD_PATH.'/';
        
        if(is_numeric($primary_key))
        {
            //image upload path for certain client
            $upload_path .= $primary_key;
            if( ! file_exists($upload_path))
            {                
                @mkdir($upload_path, 0755, TRUE);
            } 
        }    
        
        
        
        $this->load->library('image_CRUD');
        $image_crud = new image_CRUD();
	$image_crud->set_table('client_images');
        $image_crud->set_title_field('image_title');
        $image_crud->set_url_field('image_src')
                   ->set_ordering_field('image_priority')
                   ->set_language('your lang') 
                   ->set_relation_field('client_id')
                   ->set_image_path($upload_path);

	$output = $image_crud->render();	   
       
        $this->data = (object) array_merge((array) $this->data, (array) $output);
                
        //output view
        $this->load->view('admin/main_tpl', $this->data);

    }  
}  

Hope it helps! Do not just copy paste! Looking, thinking and you'll be good



#5 HPM

HPM

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 10 June 2015 - 02:13 PM

Hi paul,thank you so much for the given solution,i will try to understand and  apply it with the help of your code,thanks again for the help :)



#6 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts

Posted 11 June 2015 - 08:43 AM

you're welcome







Also tagged with one or more of these keywords: image crud, grocery crud

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users