⚠ In case you've missed it, we have migrated 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 is an archived forum. ⚠

  •     

profile picture

Callback Column



Kun Hernowo Putra
  • profile picture
  • Member

Posted 22 January 2014 - 17:15 PM

I have a problem callback column

i want to change data image with my url

 

can u help me

public function banner(){
            if($this->session->userdata('logged_in')){
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
            $this->load->view('home_view', $data);
         
            }else{
            //If no session, redirect to login page
            redirect('login', 'refresh');
            }
            $crud = new grocery_CRUD();
            $crud->set_table('banner');
            $crud->set_subject('banner');
            $crud->columns('title','content','image');
            $crud->set_field_upload('image','../images/banner');
            $crud->set_field_upload('imageEng','../images/banner');
            $crud->callback_before_insert(array($this,'set_value_banner'));
            $crud->callback_after_update(array($this, 'set_value_banner'));
		=>>	$crud->callback_column('image',array($this,'image_url'));
            $output = $crud->render();
            $this->banner_crud($output);        
    }
    function banner_crud($output = null){
            $this->load->view('banner_crud.php',$output);    
    }

    function set_value_banner($post_array) {
			$post_array['image'] = 'banner/' . $post_array['image'];
			return $post_array;
			}  
	
	function image_url(){
			$path=base_url();
			$image = "<img src='../images/banner";
			return $image;
			}  

Tx  before :)


victor
  • profile picture
  • Member

Posted 23 January 2014 - 00:44 AM

Learn documentation: http://www.grocerycrud.com/documentation/options_functions/callback_column

Callback fucntion get two params $value and $row.

function image_url($value,$row){
$image = '<img src='.base_url().'/images/banner/'.row->image;
return $image;
}

or explain in more words what you want