我有以下代码:
<ul class="navigation">
<?php foreach( $this->navigation as $item ): ?>
<li class="<?php if($item->isActive()){echo " active";}?>">
<div class="shadow"></div>
<div class="tab"><?php echo $this->htmlLink($item->getHref(), $this->translate($item->getLabel())) ?></div>
</li>
<?php endforeach; ?>
</ul>
该$item->isActive()
作品仅适用于主页。在所有其他页面上,class="active" 没有出现。
更新:
该应用程序使用如下路由:
// Routes --------------------------------------------------------------------
'routes' => array(
'home' => array(
'route' => '/',
'defaults' => array(
'module' => 'core',
'controller' => 'index',
'action' => 'index'
)
),
'core_home' => array(
'route' => '/',
'defaults' => array(
'module' => 'core',
'controller' => 'index',
'action' => 'index'
)
),
'confirm' => array(
'route'=>'/confirm',
'defaults' => array(
'module'=>'core',
'controller'=>'confirm',
'action'=>'confirm'
)
),
// Admin - General
'core_admin_settings' => array(
'route' => "admin/core/settings/:action/*",
'defaults' => array(
'module' => 'core',
'controller' => 'admin-settings',
'action' => 'index'
),
'reqs' => array(
'action' => '\D+',
)
),
)
路由保存在一个名为 manifest.php 的文件中