簡體   English   中英

默認布局cakePHP

[英]Default layout cakePHP

我有一個簡單的問題,我嘗試使用一種帶有頁眉和頁腳的默認布局在制作它們時自動顯示在其他.ctp文件中,但是由於某些原因我無法做到這一點,並且我也在考慮使用一個JavaScript文件來也可以在其他所有頁面上顯示,有人可以舉例說明如何使一個默認文件的頁眉和頁腳顯示在所有其他文件上。

謝謝您的幫助

這是您的default.ctp的示例

default.thtml中

<html>
<head>
    <!-- 
    //here your javascript yourscript.js 
    //It will be present in all your views.
    //the file has to be present in /app/webroot/js 
    -->
    echo $this->Html->script('yourscript');

</head>
<body>

    <!--
    //header
    //the file header.ctp has to be present in /View/Elements
    -->
    echo $this->element('header');

    <!--
    //here the content, for example from /View/Posts/edit.ctp
    -->
    echo $this->fetch('content');

    <!--
    //footer
    //the file footer.ctp has to be present in /View/Elements
    -->
    echo $this->element('footer');

</body>
</html>

$ this-> fetch('content')成為CakePHP的“魔術”部分。 這里將獲取您的觀點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM