I want to ask how to make if else function menu with active class. here is my code in controller.
public function index(){
//i try with this but 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 with this but 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 is my 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 with this but 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 with activetabs, but error. please help me, thankyou. I'll try with activetabs, but error. please help me, thankyou. I'll try with activetabs, but error. please help me, thankyou.
Aucun commentaire:
Enregistrer un commentaire