CakePhp打印控制器&功能不是


CakePhp print if controller & function is not

我正试图写一个if语句放入CakePhp模板。

基本上我想在除1页以外的所有页面上打印一段代码。当控制器为user且执行该控制器中的page函数时,生成该页。

这是我目前为止写的:

<?php
    echo $this->Html->meta('icon');
    echo $this->Html->script(array('jqueryTouchSwipe.min', 'custom'));
    if($this->params['controller'] != 'users'){
        echo $this->Html->script('jquery.onp.sociallocker.1.7.6.min');
        echo $this->Html->script('box');
    }
    echo $this->fetch('meta');
    echo $this->fetch('script');
?> 

然而,这只说明控制器不是用户,而不说明功能。

任何想法?

您应该能够使用$this->params['action']:-

if ($this->params['controller'] !== 'users' && $this->params['action'] !== 'page') {
    echo $this->Html->script('jquery.onp.sociallocker.1.7.6.min');
    echo $this->Html->script('box');
}