PHP - Move Controller to Codeigniter view/ Active menu

Asked

Viewed 102 times

0

I want to make an active menu shape stay colored, so I separated my template has:

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

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

In the view I did:

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

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

And

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

Already on the controller:

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

But get back to 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 I’m not correctly loading/calling the variable.

1 answer

0


Your problem is the kind of data you’re trying to send into view

this is waiting for an array with the data

you must correct in your controller for something of the kind

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

then in the view to access Variabel

 $current

Browser other questions tagged

You are not signed in. Login or sign up in order to post.