リスト項目に class="active" を追加して、選択したメニューを強調表示したいのですが、php に詳しくないので、これを行う方法がわかりませんでした。
これは私がtplファイルに持っているものです
<ul class="menu">
<li>
<a<?php echo $target; ?> href="<?php echo $link; ?>"<?php echo $nofollow; ?>><?php echo $this->escape_html($link_title); ?></a>
<?php echo $sub_menu; ?>
</li>
そしてphpファイルで
$links = $this->db->GetAll($query);
foreach($links as $link) {
$template = $this->PMDR->getNew('Template');
$template->set('link',$link['url']);
$template->set('link_title',$link['title']);
$template->set('nofollow',($link['nofollow'] ? ' rel="'.$link['nofollow'].'"' : ''));
$template->set('target',($link['target'] ? ' target="'.$link['target'].'"' : ''));
$template->set('indent',str_repeat(' ',$level));
ob_start();
$this->getMenuLoop($link['id'], $level+1);
$sub_menu = ob_get_clean();
if(!empty($sub_menu)) {
$menu_template = $this->PMDR->getNew('Template',$this->template);
$menu_template->set('items', $sub_menu);
$sub_menu = $menu_template->render();
}
$template->set('sub_menu', $sub_menu);
echo $template->render($this->item_template);
}
}
前もって感謝します!