「ver4/関数リファレンス/getContentsMenu」の版間の差分
提供: baserCMS公式ガイド
Katokaisya (トーク | 投稿記録) |
|||
(2人の利用者による、間の2版が非表示) | |||
行2: | 行2: | ||
## 説明 | ## 説明 | ||
− | + | コンテンツメニューを取得する。<br> | |
− | + | ログインしていない場合はキャッシュする。 | |
− | + | ||
− | + | ||
## 使い方 | ## 使い方 | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | $this->BcBaser->getContentsMenu( $id , | + | <?php $this->BcBaser->getContentsMenu( [$id] , [$level] , [$currentId] ); ?> |
</syntaxhighlight> | </syntaxhighlight> | ||
## パラメータ | ## パラメータ | ||
(mixed) $id | (mixed) $id | ||
− | : | + | : コンテンツID。指定したIDのコンテンツを表示する ※ID指定できるのはフォルダのみ |
− | + | : - 初期値: null | |
− | + | : コンテンツIDは、'''編集画面 > その他情報 > コンテンツID''' から確認できます。 | |
(int) $level | (int) $level | ||
− | : | + | : 階層。指定した階層までを表示する |
− | + | : - 初期値 : null <br /> | |
− | + | : ※ null の場合は階層指定なし | |
− | + | ||
(string) $currentId | (string) $currentId | ||
− | : | + | : 現在のページのコンテンツID。指定したコンテンツ名に.currentを付与する |
− | + | : - 初期値 : null | |
− | + | ||
− | + | ||
## 戻り値 | ## 戻り値 | ||
− | (string) コンテンツメニュー | + | (string) |
+ | : コンテンツメニュー | ||
## 用例 | ## 用例 | ||
### 基本 | ### 基本 | ||
+ | コンテンツメニューを取得し、echoで出力する。 | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | + | <?php echo $this->BcBaser->getContentsMenu(); ?> | |
</syntaxhighlight> | </syntaxhighlight> | ||
####出力 | ####出力 | ||
<syntaxhighlight lang="html5"> | <syntaxhighlight lang="html5"> | ||
− | + | <ul class="menu ul-level-2"> | |
+ | <li class="menu-content li-level-2"><a href="/service/service1">サービス1</a></li> | ||
+ | <li class="menu-content li-level-2"><a href="/service/service2">サービス2</a></li> | ||
+ | <li class="menu-content li-level-2"><a href="/service/service3">サービス3</a> | ||
+ | <ul class="menu ul-level-3"> | ||
+ | <li class="menu-content li-level-3"><a href="/service/service3/page01">サービス3-A</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | </ul> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
### 応用 | ### 応用 | ||
+ | サービスフォルダ(コンテンツID 6)内のメニューを第1階層まで表示し、<br> | ||
+ | サービス2(コンテンツID 12)に.currentを付与するコンテンツメニューを、echoで出力する。 | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | + | <?php $this->BcBaser->contentsMenu(6,1,12); ?> | |
</syntaxhighlight> | </syntaxhighlight> | ||
####出力 | ####出力 | ||
<syntaxhighlight lang="html5"> | <syntaxhighlight lang="html5"> | ||
− | + | <ul class="menu ul-level-1"> | |
+ | <li class="menu-content li-level-1"><a href="/service/service1">サービス1</a></li> | ||
+ | <li class="menu-content li-level-1 current"><a href="/service/service2">サービス2</a></li> | ||
+ | <li class="menu-content li-level-1"><a href="/service/service3">サービス3</a></li> | ||
+ | </ul> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
##類似の関数 | ##類似の関数 | ||
− | + | - [contentsMenu](/ver4/関数リファレンス/contentsMenu) - コンテンツメニューを出力する | |
− | + | ||
− | [ | + |
2018年12月13日 (木) 00:26時点における最新版
[このコンテンツは内容調整中です]
説明
コンテンツメニューを取得する。
ログインしていない場合はキャッシュする。
使い方
<?php $this->BcBaser->getContentsMenu( [$id] , [$level] , [$currentId] ); ?>
パラメータ
- (mixed) $id
- コンテンツID。指定したIDのコンテンツを表示する ※ID指定できるのはフォルダのみ
- - 初期値: null
- コンテンツIDは、編集画面 > その他情報 > コンテンツID から確認できます。
- (int) $level
- 階層。指定した階層までを表示する
- - 初期値 : null
- ※ null の場合は階層指定なし
- (string) $currentId
- 現在のページのコンテンツID。指定したコンテンツ名に.currentを付与する
- - 初期値 : null
戻り値
- (string)
- コンテンツメニュー
用例
基本
コンテンツメニューを取得し、echoで出力する。
コード
<?php echo $this->BcBaser->getContentsMenu(); ?>
出力
<ul class="menu ul-level-2"> <li class="menu-content li-level-2"><a href="/service/service1">サービス1</a></li> <li class="menu-content li-level-2"><a href="/service/service2">サービス2</a></li> <li class="menu-content li-level-2"><a href="/service/service3">サービス3</a> <ul class="menu ul-level-3"> <li class="menu-content li-level-3"><a href="/service/service3/page01">サービス3-A</a></li> </ul> </li> </ul>
応用
サービスフォルダ(コンテンツID 6)内のメニューを第1階層まで表示し、
サービス2(コンテンツID 12)に.currentを付与するコンテンツメニューを、echoで出力する。
コード
<?php $this->BcBaser->contentsMenu(6,1,12); ?>
出力
<ul class="menu ul-level-1"> <li class="menu-content li-level-1"><a href="/service/service1">サービス1</a></li> <li class="menu-content li-level-1 current"><a href="/service/service2">サービス2</a></li> <li class="menu-content li-level-1"><a href="/service/service3">サービス3</a></li> </ul>
類似の関数
- contentsMenu - コンテンツメニューを出力する