個人用ツール

「関数リファレンス/Blog getTag」の版間の差分

提供: baserCMS公式ガイド

移動: 案内, 検索
 
行28: 行28:
 
####コード
 
####コード
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
     <?php $this-Blog->getTag($post) ?>
+
     <?php $this->Blog->getTag($post) ?>
 
</syntaxhighlight>
 
</syntaxhighlight>
 
####出力
 
####出力

2016年9月7日 (水) 12:32時点における最新版

説明

ブログテンプレート内に記述することで、タグを取得できます。

使い方

    <?php $this->Blog->getTag($post, [$separator]) ?>

パラメーター

$post
ブログ記事のデータを指定します。ブログ記事を出力するループ内では「$post」と記述すれば動作します。
$separator
複数のタグに属する記事の場合、タグの区切り文字を指定。 初期値: ','

戻り値

(strign)
文字列が返されます。

用例

基本

コード

    <?php $this->Blog->getTag($post) ?>

出力

    <a href="/products/archives/tag/%E3%81%94%E8%87%AA%E5%AE%85%E7%94%A8">ご自宅用</a>

応用

コード

    <?php $this->Blog->getTag($post, '|'); ?>

出力

<a href="/products/archives/tag/%E3%81%94%E8%B4%88%E7%AD%94%E7%94%A8">ご贈答用</a>|<a href="/products/archives/tag/%E3%81%94%E8%87%AA%E5%AE%85%E7%94%A8">ご自宅用</a>

変更履歴

ソースファイル

関連資料

擬似の関数