我正在學習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>
,
但這些代碼會出現在每個網頁中,而不僅僅是一個特定的網頁。
請幫忙。