添加到< body> CakePHP应用程序的标签 [英] Add to <body> tag of a cakePHP app
本文介绍了添加到< body> CakePHP应用程序的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,我需要调用一些JS在onLoad事件的BODY标签的两种形式。但是,我找不到如何修改标签只为他们。有人知道吗?
I have an app where I need to call some JS in the onLoad event of the BODY tag of two forms. However, I can't find how to modify the tag for just them. Does anyone know?
Frank
推荐答案
inkedmn 肯定为这种情况提供了正确的答案,但一般来说,你可以手动信息向上像这样:
inkedmn certainly has provided the right answer for this case, but in general, you can "hand information up" like this:
(在views / controller / view。 ctp)
(in views/controller/view.ctp)
$this->set('bodyAttr', 'onload="something"');
(在views / layouts / default.ctp中)
(in views/layouts/default.ctp)
<?php
if (isset($bodyAttr)) {
$bodyAttr = " $bodyAttr";
} else {
$bodyAttr = null;
}
?>
<body<?php echo $bodyAttr; ?>>
我经常使用它来向顶级元素添加额外的类:
I often use it like this to add extra classes to a "top level element":
<?php
if (!isset($docClass)) {
$docClass = null;
}
?>
<div id="doc" class="<?php echo $docClass; ?>">
这篇关于添加到< body> CakePHP应用程序的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文