Welcome Guest, Not a member yet? Register   Sign In
Passing more than one variable in a template view??
#1

[eluser]Skoobi[/eluser]
Hi im trying to add an image CRUD plugin to my CMS which i done through Tuts but im getting

Message: Undefined variable: output

Which is obviously the variable $output is not getting passed through. But the problem i have is that i cant figure out how to pass it with the setup i have...

Heres the controller
Code:
<?php

class Gallery extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->library('image_CRUD');
    }


    
    function _example_output($output = null)
    {
        
        $this->data['subview'] = "admin/gallery/index";
        $this->load->view('admin/_layout_main', $this->data);  
        var_dump($output);
    }
    
    function index()
    {  
        $this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
    }  
    
    function view()
    {
        $image_crud = new image_CRUD();
        
        $image_crud->set_primary_key_field('id');
        $image_crud->set_url_field('url');
        $image_crud->set_table('example_1');
        $image_crud->set_image_path('assets/uploads');
            
        $output = $image_crud->render();
        
        $this->_example_output($output);
    }
}

Any help or pointers would be most greatful...

Many Thanks
#2

[eluser]CroNiX[/eluser]
You never pass $output to the view. The only thing you are passing is "subview":
Code:
function _example_output($output = null)
{      
  $this->data['subview'] = "admin/gallery/index";
  $this->load->view('admin/_layout_main', $this->data);  
  var_dump($output); //I assume this one works but you are having problems only in the view?
}
#3

[eluser]Skoobi[/eluser]
Ye im getting the var_dump through but not to the view but i'm not sure what i need to do to get it to the view!! many thanks for your reply
#4

[eluser]CroNiX[/eluser]
Same thing you are doing here:
Code:
$this->data['subview'] = "admin/gallery/index";
#5

[eluser]Skoobi[/eluser]
so if im following id have it like this in the

Code:
class Gallery extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->library('image_CRUD');
    }


    
    function _example_output($output = null)
    {
        $this->data['gallery'] = $output;
        $this->data['subview'] = "admin/gallery/index";
        $this->load->view('admin/_layout_main', $this->data);  
        var_dump($output);
    }
    
    function index()
    {  
        $this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
    }  
    
    function view()
    {
        $image_crud = new image_CRUD();
        
        $image_crud->set_primary_key_field('id');
        $image_crud->set_url_field('url');
        $image_crud->set_table('example_1');
        $image_crud->set_image_path('assets/uploads');
            
        $output = $image_crud->render();
        
        $this->_example_output($output);    
    }
}
#6

[eluser]Skoobi[/eluser]
Sorry for the complete beginner questions...

Im getting this error when i do this

Code:
A PHP Error was encountered

Severity: 4096

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

Filename: gallery/index.php

Line Number: 4
#7

[eluser]CroNiX[/eluser]
Try
Code:
function _example_output($output = null)
{
  $data['gallery'] = $output; //in view, access as $gallery['output'], etc
  $data['subview'] = "admin/gallery/index";
  $this->load->view('admin/_layout_main', $data);  
  var_dump($output);
}
    
function index()
{  
  $this->_example_output(array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
#8

[eluser]Skoobi[/eluser]
ye still getting

Code:
A PHP Error was encountered

Severity: 4096

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

Filename: gallery/index.php

Line Number: 4

Sad
#9

[eluser]CroNiX[/eluser]
What url are you calling?
#10

[eluser]Skoobi[/eluser]
index view




Theme © iAndrew 2016 - Forum software by © MyBB