「ver4/関数リファレンス/getPostDetail」を編集中
提供: baserCMS公式ガイド
警告: ログインしていません。
編集すると、IPアドレスがこのページの編集履歴に記録されます。この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
行25: | 行25: | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | + | $BlogPost = ClassRegistry::init('BlogPost'); | |
+ | $post = $BlogPost->find('first', ['conditions' => ['BlogPost.id' => 1]]); | ||
+ | $this->Blog->getPostDetail($post); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
####出力 | ####出力 | ||
− | + | IDが1のブログ記事本文 | |
### 応用 | ### 応用 | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | + | $BlogPost = ClassRegistry::init('BlogPost'); | |
+ | $post = $BlogPost->find('first', ['conditions' => ['BlogPost.id' => 1]]); | ||
+ | $options = ['cut' => 30]; | ||
+ | $this->Blog->getPostDetail($post, $options); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
####出力 | ####出力 | ||
− | + | 30文字にカットされたIDが1のブログ記事本文 | |
[[Category:関数リファレンスver4]] | [[Category:関数リファレンスver4]] |