PHP - Pass Controller Variable to the CodeIgniter / Active Menu View

0

I want to make a form of the active menu stay colorful, so I separated my template has:

View: Menu_lateral.php - place where the side menu is;

Controller: General: Where would I tell which menu is active;

In the view I did:

<?php
    $ativo = array();
    $ativo[0] = "";

    $ativo[$current] = 'class="active"';
?>

E

<li class="nav-item <?php echo $ativo[0];?> ">

Already in the controller:

$this->load->view('dashboard/template/menu_lateral', $current = 0);

But it returns me:

A PHP Error was encountered
Severity: Notice

Message: Undefined variable: current

Filename: template/menu_lateral.php

Line Number: 5

Backtrace:

File: C:\xampp\htdocs\teste\application\views\dashboard\template\menu_lateral.php
Line: 5
Function: _error_handler

File: C:\xampp\htdocs\teste\application\controllers\Geral.php
Line: 10
Function: view

I believe that I am not loading correctly / correctly calling the variable.

    
asked by anonymous 10.07.2018 / 02:16

1 answer

0

Your problem is in the type of data you are trying to send to the view

This is waiting for an array with the data

You should fix it in your controller for something of the genre

$this->load->view('dashboard/template/menu_lateral', array('current' => 0));

then in view to access variabel

 $current
    
13.07.2018 / 13:43