php - How to make if else menu with active class in codeigniter -


i want ask how make if else function menu active class. here code in controller.

public function index(){      //i try error      $data['activetab'] == "home";      $this->load->view('head');     $this->load->view('header');      $this->load->view('content',$data);      $this->load->view('footer');     $this->load->view('foot'); }  public function about(){      //i try error     $data['activetab'] == "about";      $this->load->view('head');     $this->load->view('header');      $this->load->view('content-about',$data);      $this->load->view('footer');     $this->load->view('foot'); } 

and here view

<body>   <div class="container">     <div class="row">         <!--header start-->             <div class="page-header">             <a href="<?php echo base_url();?>codeig/index.php/site">header</a>             </div>         <!--header end-->          <!--navbar start-->             <nav class="navbar navbar-default">                 <div class="navbar-header">                     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">                         <span class="sr-only">toggle navigation</span>                         <span class="icon-bar"></span>                         <span class="icon-bar"></span>                         <span class="icon-bar"></span>                     </button>                 </div>                 <div id="navbar" class="collapse navbar-collapse">                     <ul class="nav navbar-nav">                         <!--i try error-->                         <li class="<?php echo ($activetab=="home")?"active":""; ?>"><a href="<?php echo base_url();?>codeig/index.php/site">home</a></li>                         <li><a href="<?php echo base_url();?>codeig/index.php/site/about">about</a></li>                         <li><a href="#contact">contact</a></li>                     </ul>                 </div>             </nav>         <!--navbar end--> 

i'll try activetabs. there error.

change

$data['activetab'] == "home"; $data['activetab'] == "about"; 

this

$data['activetab'] = "home"; $data['activetab'] = "about"; 

if use ==, error

severity: notice
message: undefined variable: activetab
filename: xx/yyy.php
line number: xxx


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -