php - Codeigniter data passing to landing page, but not to other page -
i trying use image crud in codeigniter. following have working:
controller:
public function view($page = 'home') { $image_crud = new image_crud(); $image_crud->unset_upload(); $image_crud->unset_delete(); $image_crud->set_primary_key_field('id'); $image_crud->set_url_field('url'); $image_crud->set_table('example_4') ->set_image_path('assets/uploads'); $output = $image_crud->render(); $this->load->view('pages/'.$page,$output); }
view:
<html> <body><div class="container_main"> <?php echo $output; ?> </div>
the page display code. however, once add additional page page give me error:
a php error encountered severity: notice message: undefined variable: output filename: pages/gallery.php line number: 7
new controller:
public function view($page = 'home') { if($page == 'gallery'){ $image_crud = new image_crud(); $image_crud->unset_upload(); $image_crud->unset_delete(); $image_crud->set_primary_key_field('id'); $image_crud->set_url_field('url'); $image_crud->set_table('example_4') ->set_image_path('assets/uploads'); $output = $image_crud->render(); $this->load->view('pages/'.$page,$output); } }
what doing wrong?
try
on view :-
print_r($data);
also need change args in function
public function view($page) { $page = (!empty($page) ? $page :'home'); if($page == 'gallery'){ $image_crud = new image_crud(); $image_crud->unset_upload(); $image_crud->unset_delete(); $image_crud->set_primary_key_field('id'); $image_crud->set_url_field('url'); $image_crud->set_table('example_4') ->set_image_path('assets/uploads'); $data['output']= $image_crud->render(); $data['page'] = $page; $this->load->view('pages/'.$page,$data); } else { $data['page'] = $page; $this->load->view('pages/'.$page,$data); } }
Comments
Post a Comment