Problem with nested menu

Hey there.
I want to create an off-canvas menu, including all visible pages below $site, their children and grandchildren.
This is what I have:

<?php
  $items = $site->children()->visible();
  if($items->count()) :
?>
<nav class="off-canvas position-right" id="offCanvasRight" data-off-canvas data-transition="overlap" data-content-scroll="false">
  <ul class="vertical menu" data-accordion-menu data-multi-open="false">
    <?php foreach($items as $item) : ?>
      <li>
        <a<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>">
          <?= $item->title()->html() ?>
        </a>

        <?php
          $items = $item->children()->visible();
          if($items and $items->count()):
        ?>
          <ul class="nested menu vertical<?php e($item->isOpen(), ' is-active') ?>">
            <?php foreach($items as $item) : ?>
            <li>
              <a<?php e($item->isOpen(), ' class="is-active"') ?> href="<?= $item->url() ?>">
                <?php if($item->volume()) : ?>
                  Vol. <?= $item->volume() ?>, Nr. <?= $item->number() ?> <?php e($item->number()->int() == 1, '(Winter ', '(Summer ') ?><?= $item->date('Y', 'year') ?>)
                <?php else : ?>
                  <?= $item->title()->html() ?>
                <?php endif ?>
              </a>
              <?php
                $items = $item->children()->visible();
                if($items and $items->count()):
              ?>
                <ul class="nested menu vertical<?php e($item->isOpen(), ' is-active') ?>">
                  <?php foreach($items as $item) : ?>
                  <li>
                    <a<?php e($item->isOpen(), ' class="is-active"') ?> class="accordion-title" href="<?= $item->url() ?>">
                      <?= $item->title()->html() ?>
                    </a>
                  </li>
                  <?php endforeach ?>
                </ul>
              <?php endif ?>
            </li>
          <?php endforeach ?>
        </ul>
      <?php endif ?>
    </li>
    <?php endforeach ?>
  </ul>
</nav>
<?php endif ?>

However, what I am not getting is this: I want to change the displayed link text for every item on the second level that meets certain criteria (doesn’t matter which one I choose, be it template (the second-level items I’m targeting are the only pages with that specific template), parent (the second-level items I’m targeting are the only children of that specific parent), …), BUT I don’t know HOW to address or target them correctly - It only works if I am not currently browsing on these second-level items’ pages or one of their children …

// Edit:
The code above shows <?php if($item->volume()) : ?>, but that’s only one approach I tried … volume() is a field only the pages I am targeting has …

In the case of $item->volume() you have to check if that field is empty or not:

if($item->volume()->isNotEmpty()):
// do something
endif;

Well, doesn’t do much, it seems to depend on the page I’m currently on …
I got this structure:

issues/specific-issue/some-article
1st-level/2nd-level/3rd-level

Now, if I am currently on issue page or ANY other page, everything looks as planned (below Issues are three volumes, each has up to nine articles); if however I am on the page of a certain volume (2nd-level) OR the page of some article (3rd-level), I only see 2volumes (the ones I am not visiting currently)

well, i am sorry, it seems to be a case of “Foundation 6 wildly inserted display: none”

i am so sorry …

I was just gonna say, check the source code… :wink:

You are a wise woman indeed, for you met so many people not checking their source code :slight_smile:

@daybugging do you remember the fix you did with foundation? I am facing the same issue and stuck.

@AdityaNayak If you have a look at your source code in dev tools, I’m sure you will find what foundation is hiding.

Yes, I am looking for the fix that @daybugging may have found to prevent foundation’s this behavior.