⚠ 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

Paasing $output variable through a array



sourov08
  • profile picture
  • Member

Posted 27 October 2014 - 07:49 AM

Here is the code controller code .... I want to paas $output variable through a array in view file .

         function test()
         {
        $crud = new grocery_CRUD();
            $crud->set_table('tickets');
            $crud->set_subject('Order');        
            $crud->unset_delete();
                $output = $crud->render();
            

                $data = array(
            'title' => "Unsolved Tickets ! ",                          
            'page_heading' => "Unsolved tickets ! ",                          
               'tickets' => $this->admin_model->load_unsolved_tickets(),
               'dir' => FOLDER_UNSOLVED_TICKETS,
            'page' =>'index.php',
            'details_url' => FOLDER_ADMIN.'/ticket_details' ,       
            'output'      =>  $output
            
                 );
                $this->load->data('example' , $data);

          }

if $output varriable passing through via array  then what will be view file code to see the datatable or grid .
what change will appear in view file code ,like  
           <?php
              foreach($css_files as $file): ?>
            <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
             <?php endforeach; ?>
             <?php foreach($js_files as $file): ?>
            <script src="<?php echo $file; ?>"></script>
             <?php endforeach; ?>
             <?php echo $output;
 

 


Amit Shah
  • profile picture
  • Member

Posted 27 October 2014 - 08:41 AM

i will rather recommend it the other way around...

 

$data = array(
            'title' => "Unsolved Tickets ! ",                          
            'page_heading' => "Unsolved tickets ! ",                          
               'tickets' => $this->admin_model->load_unsolved_tickets(),
               'dir' => FOLDER_UNSOLVED_TICKETS,
            'page' =>'index.php',
            'details_url' => FOLDER_ADMIN.'/ticket_details' );

 

$output->data = $data;

$this->load->view('example',$output);

 

the same in the view can the be accessed as

 

<?= $data['title'] ?> and so on


sourov08
  • profile picture
  • Member

Posted 02 November 2014 - 20:04 PM

I find a solution and this is here ...
This is my controller :
 
$crud = new grocery_CRUD();
$crud->set_table('tickets');
$crud->set_subject('Order');
$output = $crud->render();
 
       $data = array(
    'title' => "Unsolved Tickets ! ",                      
       'page_heading' => "Unsolved tickets ! ",                      
       'output'      =>  $output,
       );      
 
$this->load->view('example',$data);  
 
and this is my view file :
<?php  
foreach($output->css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
 
 
<?php foreach($output->js_files as $file):  ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
 
                        <?php echo $output->output;   ?>