「ver4/関数リファレンス/title」の版間の差分
提供: baserCMS公式ガイド
Katokaisya (トーク | 投稿記録) |
Webbingstudio (トーク | 投稿記録) (version 3.0.10以降の第二引数の解説を追加) |
||
行1: | 行1: | ||
## 説明 | ## 説明 | ||
− | + | METAのtitleを出力する。 | |
− | + | ||
## 使い方 | ## 使い方 | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | $this->BcBaser->title($separator , $ | + | $this->BcBaser->title($separator , $options ); |
</syntaxhighlight> | </syntaxhighlight> | ||
## パラメーター | ## パラメーター | ||
(string) $separator | (string) $separator | ||
− | : | + | : 階層の区切り文字を指定する。 初期値 = '|' |
− | + | ||
− | ( | + | (array) $options |
− | : | + | : categoryTitleOn : カテゴリを表示するかを boolean で指定。falseで表示しない 初期値 = null |
+ | : tag : タグが記述されていた場合、どのように扱うかを boolean で指定。trueでエンコードして出力、falseで除去する 初期値 = true | ||
+ | : allowableTags : tagがfalseだった場合、**除去しない**タグをPHPの[strip_tags](http://php.net/manual/ja/function.strip-tags.php)の書式で指定 初期値 = '' | ||
+ | |||
+ | 以下、ソースより引用 | ||
+ | version 3.0.10 より第2引数 $categoryTitleOn は、 $options にまとめられました。 | ||
+ | 後方互換のために第2引数に配列型以外を指定された場合は、 $categoryTitleOn として取り扱います。 | ||
## 用例 | ## 用例 | ||
### 基本 | ### 基本 | ||
+ | |||
+ | タイトルが「サービス1」、カテゴリーが「サービス」、サイト名が「baserCMS inc.」だった場合 | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | <?php $this->BcBaser->title( | + | <?php $this->BcBaser->title() ?> |
</syntaxhighlight> | </syntaxhighlight> | ||
####出力 | ####出力 | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="html5"> |
− | <title> | + | <title>サービス1|サービス|baserCMS inc.</title> |
</syntaxhighlight> | </syntaxhighlight> | ||
### 応用 | ### 応用 | ||
+ | |||
+ | タイトルが「<em>サービス</em><strong>1</strong>」、カテゴリーが「サービス」、サイト名が「baserCMS inc.」だった場合 | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | + | <?php | |
+ | $args = array( | ||
+ | 'categoryTitleOn' => false, | ||
+ | 'tag' => false, | ||
+ | 'allowableTags' => '<strong>' | ||
+ | ); | ||
+ | $this->BcBaser->title(' : ', $args); | ||
+ | ?> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
####出力 | ####出力 | ||
+ | |||
+ | <syntaxhighlight lang="html5"> | ||
+ | <title>サービス<strong>1</strong> : baserCMS inc.</title> | ||
+ | </syntaxhighlight> | ||
## 注 | ## 注 | ||
+ | |||
+ | BcBaser->titleはtitleタグも含めて出力される。ページタイトルとして文字列のみ出力したい場合は、[BcBaser->contentsTitle](http://wiki.basercms.net/ver4/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/contentsTitle)を使用する。 | ||
## 変更履歴 | ## 変更履歴 | ||
+ | ### 2018-06-04 | ||
+ | |||
+ | - version 3.0.10以降の第二引数の解説を追加 | ||
## ソースファイル | ## ソースファイル | ||
+ | https://github.com/baserproject/basercms/blob/master/lib/Baser/View/Helper/BcBaserHelper.php | ||
## 関連資料 | ## 関連資料 | ||
[[Category:関数リファレンス]] | [[Category:関数リファレンス]] |
2018年6月4日 (月) 01:35時点における版
目次
説明
METAのtitleを出力する。
使い方
$this->BcBaser->title($separator , $options );
パラメーター
- (string) $separator
- 階層の区切り文字を指定する。 初期値 = '|'
- (array) $options
- categoryTitleOn : カテゴリを表示するかを boolean で指定。falseで表示しない 初期値 = null
- tag : タグが記述されていた場合、どのように扱うかを boolean で指定。trueでエンコードして出力、falseで除去する 初期値 = true
- allowableTags : tagがfalseだった場合、除去しないタグをPHPのstrip_tagsの書式で指定 初期値 =
以下、ソースより引用
version 3.0.10 より第2引数 $categoryTitleOn は、 $options にまとめられました。
後方互換のために第2引数に配列型以外を指定された場合は、 $categoryTitleOn として取り扱います。
用例
基本
タイトルが「サービス1」、カテゴリーが「サービス」、サイト名が「baserCMS inc.」だった場合
コード
<?php $this->BcBaser->title() ?>
出力
<title>サービス1|サービス|baserCMS inc.</title>
応用
タイトルが「サービス1」、カテゴリーが「サービス」、サイト名が「baserCMS inc.」だった場合
コード
<?php $args = array( 'categoryTitleOn' => false, 'tag' => false, 'allowableTags' => '<strong>' ); $this->BcBaser->title(' : ', $args); ?>
出力
<title>サービス<strong>1</strong> : baserCMS inc.</title>
注
BcBaser->titleはtitleタグも含めて出力される。ページタイトルとして文字列のみ出力したい場合は、BcBaser->contentsTitleを使用する。
変更履歴
2018-06-04
- version 3.0.10以降の第二引数の解説を追加
ソースファイル
https://github.com/baserproject/basercms/blob/master/lib/Baser/View/Helper/BcBaserHelper.php