我想添加一个类到我的锚链接,当它是活动的,但它不工作。我将不得不声明$操作变量呢?
版本号:
4.2.9
错误:
Undefined variable: action [ROOT\templates\layout\default.php, line 108]
templates/layout/default.php
<li>
<?= $this->Html->link(
'<div class="icon"></div>'.__('Summary'),
['controller' => 'modules', 'action' => 'summary'],
[
'escapeTitle' => false,
'class' => 'icon-summary '.( ($controller == 'Modules' && $action == 'summary') ? 'active' : '')
]
) ?>
</li>
在我的模板中
public function summary()
{
$modules = $this->getAllModules();
}
DebugKit中的路由参数
'controller' => 'Modules',
'action' => 'summary',
'pass' => [ ],
'plugin' => null,
'_matchedRoute' => '/{controller}/{action}/*',
'_ext' => null,
]
1条答案
按热度按时间zf9nrax11#
在我的
AppController.php
中,我在beforeRender()
函数中插入了下面的代码。现在我可以访问action
变量了。非常感谢