大家好,只是想问一个简单的问题。这都是关于创建导航链接的。因为我有一个导航链接。如果用户选择一个链接,该链接将被突出显示,如果用户单击另一个链接,该链接将被突出显示,而前一个链接不会。在创建我的链接时,我使用一个数组并循环它来调用动作。
这是我的代码
MY CONTROLLER
public function homepage(){
$data['title'] = "Welcome";
$data['copyright'] = date('Y');
$data['queryViewEntries'] = $this->category_model->viewAllEntry();
$data['link'] = "category";
$this->load->view('common/header_common',$data);
$this->load->view('common/navigation',$data);
$this->load->view('User/contents/homepage');
$this->load->view('common/footer_common',$data);
}
MY VIEW
<li class="nav-header"></li>
<?php
$highlight = $link;
$section = array(
'CATEGORIES' => 'user_controller/homepage',
'ITEMS' => 'item_controller/index',
'SUPPLIERS' => 'supplier_controller/index'
);
foreach($section as $key => $value){
echo "<li class='active'>".anchor($value,$key)."</li>"; //this is the problem how can i set the cliked link to active and the other will be not.
}
?>
</li>
我希望你们能帮助我。谢谢。