⚠ 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

Undefined variable error message going to view



doveroh
  • profile picture
  • Member

Posted 02 December 2013 - 00:12 AM

Hello Everyone,

 

I am new to grocerygrud.  I think it is a great crud.  I am using codeigniter, but I am getting the following error message when I am using it with my template system:

 

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: output

Filename: desktop/mainpage.php

 

My controller:

function dashboard(){
$crud = new grocery_CRUD();
        
        $crud->set_table('clients');

        $output = $crud->render();

        $data['clientgrid'] = $crud->render();  
        

        // Load the DashBoard
        
        $data['desktop'] = 'desktop/mainpage';
        $this->load->view('desktop/desktop', $data);}

Desktop.php view: (template setup)

<?php $this->load->view('desktop/header'); ?>


<?php $this->load->view($desktop); ?>


<?php $this->load->view('desktop/footer'); ?>

mainpage.php view (shows the actual page)

<div id="mydashboard">

  <div class="title">My Dashboard</div>

<div class="modulecontainerleft">
  <div class="moduletitle">Client List</div>
    <div class="grid">
    
    <?php echo $output; ?>
    </div>
</div>

  </div>
</div>

If I don't go through the template system, the grid load successfully. 

 

Any suggestions or help will be greatly appreciated :)

 

 

 


Robert
  • profile picture
  • Member

Posted 03 December 2013 - 10:08 AM

In the view you echo $output; but you send $desktop, they need to be the same. That error tells you that php cant find the variable output because that var is not to the view.


doveroh
  • profile picture
  • Member

Posted 03 December 2013 - 19:40 PM

you are right.  I made the change for the output to be $clientgrid.

 

and I receive this error message:

 

A PHP Error was encountered

Severity: 4096

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

Filename: desktop/mainpage.php

Line Number: 9


Robert
  • profile picture
  • Member

Posted 05 December 2013 - 13:55 PM

You need to post 

Filename: desktop/mainpage.php

Line Number: 9

to be able to see what you did wrong


doveroh
  • profile picture
  • Member

Posted 05 December 2013 - 15:58 PM

<div id="mydashboard">

  <div class="title">My Dashboard</div>

<div class="modulecontainerleft">
  <div class="moduletitle">Client List</div>
    <div class="grid">
    
    <?php echo $output; ?>
    </div>
</div>

  </div>
</div>

It was posted above.  Line #9 is: <?php echo $output; ?>

 

I was thinking that I could do

echo $clientgrid->name_of_the_attribute   

But, I don't know what to put as the attribute for grocerycrud.