2012-05-03 13 views
0

cakephp2の 'fetch'と 'element'の違いは何ですか?私はこのコードdefault.ctpにでcakephp2の要素とフェッチ

echo $this->fetch('meta'); 

を持っており、それがありますなぜか見当もつかない。 $ this-> element( 'meta')を使うことはできません。要素フォルダにmeta.ctpを作成する必要があります。

また、このコード

echo $this->fetch('content'); 

は、コンテンツ部分です。誰かがこれを説明できますか?ありがとう。

答えて

2

fetchがデータを取得し、そこにレンダリングします。

echo $this->fetch('meta'); 

ページで定義したメタデータを取得します。

echo $this->Html->meta(
     'keywords', 
     'enter any meta keyword here' 
    ); 
    // Output 
    <meta name="keywords" content="enter any meta keyword here" /> 

    echo $this->Html->meta(
     'description', 
     'enter any meta description here' 
    ); 
    // Output 
    <meta name="description" content="enter any meta description here" />` 

echo $this->fetch('content');

ビューファイルで定義されているコンテンツをレンダリングします。

+0

このgvを説明していただきありがとうございます:) – gerl

関連する問題