[英]CakePhp print if controller & function is not
I'm trying to write an if statement to put into a CakePhp template. 我正在尝试编写一个if语句放入CakePhp模板中。
Basically I want to print a piece of code on all pages except 1. This page is generated when the controller is "user" and the function "page" in that controller is executed. 基本上,我想在除1之外的所有页面上打印一段代码。当控制器为“用户”并且执行该控制器中的功能“页面”时,将生成此页面。
This is what I have so far: 这是我到目前为止的内容:
<?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');
?>
However, this only accounts for the controller not being users but does not account for the function. 但是,这仅说明控制器不是用户,而不说明功能。
Any ideas? 有任何想法吗?
You should be able to use $this->params['action']
like:- 您应该可以像这样使用
$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');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.