CodeIgniter Forums

Full Version: Cannot see a variable in footer :
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi , i cannot see a variable in footer , this is my funcion in controller :

Code:
    public function lista_attivi(){
            $res=$this->articoli_model
       ->lista_completa();
          
          $data['lista']=$res;
          
          $data['ordinamento']=$this->ordinamento;
          
          $this->load->view('templates/header',$data );
          $this->load->view('templates/menu',$data );
                 
          $this->load->view('articoli/lista_articoli_attivi',$data);
                     
          $this->load->view('templates/footer',$data );
        
    
     }


This is footer :

Code:
  </div>
   </div>
    </div>
    <!-- CONTENT-WRAPPER SECTION END-->
   <section class="footer-section">
       <div class="container">
           <div class="row">


           </div>
       </div>
   </section>
     <!-- FOOTER SECTION END-->
   <!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME  -->
   <!-- CORE JQUERY  -->
   <script src="<?=base_url()?>assets/js/jquery-3.2.1.js"></script>
    
     <script type="text/javascript" src="<?=base_url()?>assets/js/jquery.dataTables.min.js"></script>

     <script type="text/javascript" src="<?=base_url()?>assets/js/dataTables.bootstrap.min.js"></script>

     <script type="text/javascript">
       $(document).ready(function () {
                $('#datatable').DataTable({
                    //Inserire il numero giusto per ordinare
                           
         
                "order": [ <?php echo $ordinamento ?>, 'asc' ]
        
                });

   
       });
   </script>
    
     <!-- BOOTSTRAP SCRIPTS  -->
   <script src="<?=base_url()?>assets/js/bootstrap.js"></script>
     <!-- CUSTOM SCRIPTS  -->
   <script src="<?=base_url()?>assets/js/custom.js"></script>
</body>
</html>

The error is : <h4>A PHP Error was encountered</h4>  <p>Severity: Notice</p> <p>Message:  Undefined variable: ordinamento</p>
If you need the variables in all views you can do this:

Quote:$this->load->vars($data);
$this->load->view('templates/header');
$this->load->view('etc');
"order": [ <?php echo $ordinamento ?>, 'asc' ]

missing semicolon. if you use <?= $ordinamento ?> then you don't need a semicolon.