baserCMS 親ディレクトリのタイトルを出したい時

2021年1月2日

baserCMS(4系)で親ディレクトリのタイトルを出力したい時はないですか?
例)
 親-子1
  -子2
  -子3
上記の場合、子1〜子3で親のタイトルを取得する方法です。

【ソース】

<?php if ($this->BcBaser->isPage()): ?>
    <?php
        $parent = $this->BcContents->getParent();
        echo '<h1>' . $parent['Content']['title'] . '</h1>';
    ?>
<?php elseif($this->BcBaser->isBlog()): ?>
    <h1><?php $this->Blog->title(); ?></h1>
<?php elseif($this->BcBaser->isMail()): ?>
    <h1><?php $this->BcBaser->contentsTitle() ?></h1>
<?php else: ?>
    <h1><?php $this->BcBaser->contentsTitle() ?></h1>
<?php endif; ?>

上記は、固定ページの場合、親要素を取得して、タイトルをH1で出力するソースです。
そのため、3階層以上のディレクトリには対応しておりません。