個人用ツール

「関数リファレンス/BcBaser blogPosts」を編集中

提供: baserCMS公式ガイド

移動: 案内, 検索

警告: ログインしていません。

編集すると、IPアドレスがこのページの編集履歴に記録されます。
この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 編集中の文章
行1: 行1:
## 説明  
+
## 説明
ブログ記事一覧出力
+
説明文サンプルテキスト。
 +
 
  
 
## 使い方
 
## 使い方
<syntaxhighlight lang="php">
+
```php
$this->BcBaser->blogPosts( $contentsName, [$num] , [$options] );
+
<code><?php echo $testtest ?></code>
</syntaxhighlight>
+
```
  
## パラメータ
 
(文字列)$contentsName
 
:  管理システムで指定したコンテンツ名
 
: 初期値 nul :全てのブログが取得対象に
 
  
(数値)$num
+
## 引数
: 記事件数
+
あり・なし
: 初期値:5
+
  
(array)$options
 
: オプション
 
 
    - 初期値:array()
 
    - 'category':カテゴリで絞り込む場合にアルファベットのカテゴリ名指定(初期値 : null)
 
    - 'tag':タグで絞り込む場合にタグ名を指定(初期値 : null)
 
    - 'year':年で絞り込む場合に年を指定(初期値 : null)
 
    - 'month':月で絞り込む場合に月を指定(初期値 : null)
 
    - 'day':日で絞り込む場合に日を指定(初期値 : null)
 
    - 'id':id で絞り込む場合に id を指定(初期値 : null)
 
    - 'keyword':キーワードで絞り込む場合にキーワードを指定(初期値 : null)
 
    - 'template':読み込むテンプレート名を指定する場合にテンプレート名を指定(初期値 : null)
 
    - 'contentsTemplate':どのブログのテンプレート名を利用するか''ブログ名''(news等)を指定(初期値 : null)※3.0.10で実装。指定方法が変更する可能性アリ
 
    - `direction` : 並び順の方向を指定 [昇順:ASC or 降順:DESC](初期値 : null)
 
    - `sort` : 並び替えの基準となるフィールドを指定(初期値 : null)
 
    - `page` : ページ数を指定(初期値 : null)
 
 
## 戻り値
 
なし
 
  
 
## 用例
 
## 用例
### 基本
 
####コード
 
<syntaxhighlight lang="php">
 
<?php $this->BcBaser->blogPosts('news', 5); ?>
 
</syntaxhighlight>
 
 
####出力
 
<syntaxhighlight lang="html5">
 
<ul>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/5">ホームページをオープンしました。</a></span></li>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/4">新商品を販売を開始しました。</a></span></li>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/3">ホームページをオープンしました。</a></span></li>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/2">新商品を販売を開始しました。</a></span></li>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/1">ホームページをオープンしました。</a></span></li>
 
</ul>
 
</syntaxhighlight>
 
 
### 応用
 
####コード
 
<syntaxhighlight lang="php">
 
<?php $this->BcBaser->blogPosts('news', 3, array('category'=>'release', 'year'=>'2014', 'template'=>'posts')); ?>
 
</syntaxhighlight>
 
 
####出力
 
<syntaxhighlight lang="html5">
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/3">ホームページをオープンしました。</a></span></li>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/2">新商品を販売を開始しました。</a></span></li>
 
    <li><span class="date">2014.11.2</span><span class="title"><a href="/news/archives/1">ホームページをオープンしました。</a></span></li>
 
</syntaxhighlight>
 
 
####コード
 
ブログの詳細記事表示中に、同じカテゴリの記事を関連記事として表示させたい場合
 
<syntaxhighlight lang="php">
 
<?php $this->BcBaser->blogPosts('news', 3, array('category'=>$post['BlogCategory']['name'])); ?>
 
</syntaxhighlight>
 
 
 
####コード:全てのブログから最新記事を取得する
 
<syntaxhighlight lang="php">
 
<?php
 
//全ブログから10件記事を取得
 
$this->BcBaser->blogPosts(null, 10, array(
 
  'contentsTemplate' => 'news' //どのブログ(post.php)を使うか
 
));
 
?>
 
</syntaxhighlight>
 
 
 
 
## 注
 
 
## 変更履歴
 
 
## ソースファイル
 
  
## 関連資料
+
- なにをなにする
 +
- なにをなにできる
  
##類似の関数
+
### テキストを使ったほげほげ
 +
なにをなにしてどうすることができます。
  
[[Category:関数リファレンス]]
+
### タイトルを使ってほげほげなサンプル
 +
なにをどうできる。これが一般的な方法です。
 +
サンプルコードの掲載

baserCMS公式ガイドへのすべての投稿は、他の利用者によって編集、変更、除去される場合があります。 あなたの投稿を、他人が遠慮なく編集するのを望まない場合は、ここには投稿しないでください。
また、投稿するのは、あなたが書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください (詳細は[[Basercms:著作権 ]]を参照)。 著作権保護されている作品を、許諾なしに投稿してはいけません!

Add Categories

関数リファレンス

  

中止 | 編集の仕方 (新しいウィンドウで開きます)