我正在学习cakePHP, 一切似乎都很好,除了我很困惑
如何使用default.ctp和什么应该放在元素文件夹。
我很困惑。我应该写什么在default.ctp
这里是我一直在使用,因为我的学习CakePHP的第一课的default.thtml中的文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $title_for_layout?></title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<!-- Include external files and scripts here (See HTML helper for more info.) -->
<?php echo $scripts_for_layout ?>
</head>
<body>
<!-- If you'd like some sort of menu to
show up on all of your views, include it here -->
<div id="header">
<div id="menu">...</div>
</div>
<!-- Here's where I want my views to be displayed -->
<?php echo $content_for_layout ?>
<!-- Add a footer to each displayed page -->
<div id="footer">...</div>
</body>
</html>
(我从这个URL http://book.cakephp.org/view/96/Layouts复制),但问题是,布局对我创建的所有网页生效。
我们来看看最近遇到的情况。
在其中一个.ctp文件中,我需要使用JQuery函数
,并且需要在.ctp文件中添加一些和标记。 这里是和标签我用:
<Script language="javascript">
$(document).ready(function()
{
// some functions here
});
</Script>
<style type="text/css">
{
#toppage{
width:800px;
}
但是,当我跟着default.thtml中的文件,
我注意到,这些标记(即<Style>
和<Script>
)碰巧出现在标签的下方。
据我所知,自定义的Javascript函数
应该放在HTML标记中。
我已经考虑在default.ctp文件中添加<Style>
和<Script>
,
但这些代码会出现在每个网页中,而不仅仅是一个特定的网页。
请帮忙。