2017-01-26 12 views
0

私はインターネットからBootstrap HTMLテンプレートをダウンロードしました。今はCakePHP(バージョン3.3)テンプレートに変換する予定です。関連するすべてのアセットファイルをコピー&ペーストしました私は3つのファイル、すなわちhead.ctpを作成しているwebroot/ folder.Alsoで、header.ctp & footer.ctp inside src/Template/Element.CakePHP v3.3でレンダリングレイアウトに関するガイダンスを探しています

は今、このHTMLテンプレートは、私たちについて、サービスを自宅のようなメニューがあり、私達に連絡etc.My質問は、私がすべきですhome.ctp、about_us.ctp、services.ctpのようなレイアウトを作成するsrc/Template/Element/Layout?contact_us.ctp inside?これらのレイアウトはどのように使用するのですか?適切なレイアウトに向けるルータを使用したいと思います。

私はcakephpにかなり新しいので、これらの基本的な質問をしてください。

+1

https://book.cakephp.org/3.0/ja/views.html#layouts – tarikul05

+0

あなたはする必要はありません。 'defaut.ctp'という単一のレイアウトを作成するだけです。内側に要素を挿入します。ページの場合、 'PagesController :: display'はそれらを簡単に処理できます。 –

+0

返信ありがとうございますが、いくつかのコードはよかったでしょう –

答えて

0
You do not need to create separate layouts for menus. In cakephp, layout is just like a template that you can use for your website and Elements are reusable blocks of code that you can use on you ctp file. 

Just create a single file in layout folder for e.g home.ctp and add head, header and footer element in that. 


    <?= $this->element('head'); ?> 
    <?= $this->element('header); ?> 
    <?= $this->fetch('content'); ?> 
    <?= $this->element('footer); ?> 

Add your title and meta tags in head element. Your menu in header element and your footer in footer element. 

Then to set this layout you can simply use following in your initialize function of controller. 

    $this->viewBuilder()->layout('home') 
関連する問題