Re: 特定のページだけを階層を含めたメニュー表示にする

2016年7月7日 at 17:01

nipper様
教えていただいたカスタマイズを試してみました
ありがとうございます

ただサイトのトップが表示されてしまいました

この方法でparentではなく
サブ階層の親を指定する方法があると良いのですが・

Re: 特定のページだけを階層を含めたメニュー表示にする

2016年7月7日 at 17:40
だぶん、下記で可能と思います。テストしてないのでたぶんですが。。。

$parent = Page::getByID($c->getCollectionParentID());

                    ↓
$parent = Page::getByID($navItems[0]->cObj->getCollectionParentID());


ただ、これは表示できるデータが0件の時にはエラーになりますので、nipperさんが書かれたソースをすべて、
if (count($navItems) > 0) {


以下に入れたほうが無難です。
 

Re: 特定のページだけを階層を含めたメニュー表示にする

2016年7月8日 at 10:05
nipperさま aclissさま
ありがとうございました
表示ができるようになりました
そもそも
ディレクトリ/index.html
の感覚があるので戸惑ってしまいます

下記のようなソースにしています
これで見た目はOKでした。欲を言えばリストの中にparentを入れたいので勉強してみます


//*** Step 2 of 2: Output menu HTML ***/


if (count($navItems) > 0) {
$th = Loader::helper('text');
$nh = Loader::helper('navigation');

$parent = Page::getByID($navItems[0]->cObj->getCollectionParentID());
$parentLink = $nh->getCollectionURL($parent);
$parentName = $th->entities($parent->getCollectionName());

echo '<p><a href="' .$parentLink. '">' .$parentName. '</a></p>';
echo '<ul class="fh5co-links">'; //opens the top-level menu

foreach ($navItems as $ni) {

echo '<li class="' . $ni->classes . '">'; //opens a nav item
echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';

if ($ni->hasSubmenu) {
echo '<ul>'; //opens a dropdown sub-menu
} else {
echo '</li>'; //closes a nav item
echo str_repeat('</ul></li>', $ni->subDepth); //closes dropdown sub-menu(s) and their top-level nav item(s)
}
}

echo '</ul>'; //closes the top-level menu
} else if (is_object($c) && $c->isEditMode()) { ?>
<div class="ccm-edit-mode-disabled-item"><?php echo t('Empty Auto-Nav Block.')?></div>
<?php }