個人用ツール

「ver4/関数リファレンス/title」を編集中

提供: baserCMS公式ガイド

移動: 案内, 検索

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

編集すると、IPアドレスがこのページの編集履歴に記録されます。
この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 編集中の文章
行1: 行1:
 
## 説明
 
## 説明
メタタグのtitleを出力する。<br>
+
METAのtitleを出力する。
ページタイトルとして文字列のみ出力したい場合は、<a href="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">contentsTitle()</a>を使用する。
+
 
+
  
 
## 使い方
 
## 使い方
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
<?php $this->BcBaser->title( [$separator] , [$options] ); ?>
+
$this->BcBaser->title($separator , $options );
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
## パラメーター
 
## パラメーター
 
(string) $separator
 
(string) $separator
: 階層の区切り文字を指定する。
+
: 階層の区切り文字を指定する。 初期値 = '|'
: - 初期値 = '|'
+
  
 
(array) $options
 
(array) $options
:`categoryTitleOn` : カテゴリを表示するかを boolean で指定。falseで表示しない。(初期値 = null)
+
: categoryTitleOn : カテゴリを表示するかを boolean で指定。falseで表示しない 初期値 = null
:`tag` : タグが記述されていた場合、どのように扱うかを boolean で指定。trueでエンコードして出力、falseで除去する。(初期値 = true)
+
: tag : タグが記述されていた場合、どのように扱うかを boolean で指定。trueでエンコードして出力、falseで除去する 初期値 = true
:`allowableTags` : tagがfalseだった場合、**除去しないタグ**をPHPの[strip_tags](http://php.net/manual/ja/function.strip-tags.php)の書式で指定。(初期値 = (空))
+
: 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.」だった場合
  
 
####コード
 
####コード
行31: 行33:
  
 
####出力
 
####出力
 +
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<title>コンテンツタイトル  | カテゴリ| サイト名</title>
+
<title>サービス1|サービス|baserCMS inc.</title>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
### 応用
 
### 応用
階層を:区切りで表示、カテゴリーを表示しない、タグを除去(&lt;srtong&gt;は除去しない)でタイトルタグを出力する。<br>
+
 
例)タイトルが**&lt;em&gt;サービス&lt;/em&gt;&lt;strong&gt;1&lt;/strong&gt;**、カテゴリーが**サービス**、サイト名が**baserCMS inc.**だった場合
+
タイトルが「&lt;em&gt;サービス&lt;/em&gt;&lt;strong&gt;1&lt;/strong&gt;」、カテゴリーが「サービス」、サイト名が「baserCMS inc.」だった場合
  
 
####コード
 
####コード
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
 
<?php
 
<?php
    $args = array(
+
$args = array(
        'categoryTitleOn' => false,
+
'categoryTitleOn' => false,
        'tag' => false,
+
'tag' => false,
        'allowableTags' => '<strong>'
+
'allowableTags' => '<strong>'
    );
+
);
    $this->BcBaser->title(' : ', $args);
+
$this->BcBaser->title(' : ', $args);
 
?>
 
?>
 
</syntaxhighlight>
 
</syntaxhighlight>
行54: 行57:
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<title>サービス<strong></strong> : baserCMS inc.</title>
+
<title>サービス&lt;strong&gt;&lt;/strong&gt; : baserCMS inc.</title>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
## 注
 +
 +
BcBaser->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
  
##類似の関数
+
## 関連資料
- [getContentsTitle](/ver4/関数リファレンス/getContentsTitle) - コンテンツタイトルを取得する
+
[[Category:関数リファレンス]]
- [contentsTitle](/ver4/関数リファレンス/contentsTitle) - コンテンツのタイトルを出力する
+
- [getTitle](/ver4/関数リファレンス/getTitle) - タイトルタグを取得する
+

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

Add Categories
Update Categories
  

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