Welcome Guest, Not a member yet? Register   Sign In
CI 3 and GroceryCrud Object Issue
#1

Okay,

Code Igniter has been great to program with. However I am running into a issue with my templating and view.

I would like to pass the grocerycrud object (rendered) to my view via the data variable, and it gives me an error.  My other pages work great, and everything is fine, EXCEPT trying to get a Grocery CRUD on one of my views.

Any help would be greatly appreciated.

Message: Object of class stdClass could not be converted to string


I have a template library, view, and controller below.

Controller:

PHP Code:
public function users()
{
$this->grocery_crud->set_table('users');
$output $this->grocery_crud->render();
 
//$this->_example_output($output); 


$arrayx = array(
        
'crud' => $output,
        
'data' => $data null,
);
$this->template->display($arrayx);
}
 
function 
_example_output($output null$data null)
 


View:

Has a PHP echo  $output


Template:
PHP Code:
<?php

class Template{

protected 
$_ci;

function 
__construct(){

$this->_ci=&get_instance();

}

function 
display($data=null){
    
$data['_assets']=$this->_ci->load->view('template/assets',$data,true);    

// Load the header (Logo, search, profile, user menu, chat, etc)
$data['_header']=$this->_ci->load->view('template/header',$data,true);

// Load the side bar profile
$data['_profile']=$this->_ci->load->view('template/profile',$data,true);

// Load the side bar (Complete menu)
$data['_sidebarmenu']=$this->_ci->load->view('template/sidebar_menu',$data,true);

// Load the footer widget (Progress bar with logout option)
$data['_sidebarfooter']=$this->_ci->load->view('template/sidebar_footer',$data,true);

// Load content for the page
//$data['_container']=$this->_ci->load->view('template/container',$data,true);

$data['_content']=$this->_ci->load->view('admin/users',$data,true);

// Load chat for the page
$data['_chat']=$this->_ci->load->view('template/chat',$data,true);

// Send data to the page
$this->_ci->load->view('template.php'$data);

}

}

?>
Reply
#2

Hi,

If you look at the documentation on GroceryCrud Website, you will see the output of render is an object with the folowing 3 properties: output, js_files and css_files.

So in your example your $output variable can not be echo as it is an object you need to echo the output property:

PHP Code:
echo $output->output
A good decision is based on knowledge and not on numbers. - Plato

Reply




Theme © iAndrew 2016 - Forum software by © MyBB