The submenu does not appear

The submenu does not appear, the product structure is products - categories - and here all the categories.
this is the code:


I think chaining ->children()->children() doesn’t work. You need ->grandChildren().

Also: please post code as text, and not as an image please :slight_smile:

I’m sorry.
I entered grandChildren () but it doesn’t work

// main menu items
$items = $pages->visible();


<?php foreach($items as $item): ?>
  <li <?php if ($item->children()->visible()->count() != 0):?> class="dropdown uppercase" <?php endif; ?>>
    <a class="nav-link grande <?php e($item->isOpen(), 'active') ?> <?php if ($item->children()->visible()->count() != 0): echo 'dropdown-toggle'; endif; ?>" href="<?= $item->url() ?>">
      <?= $item->title()->html() ?><?php if ($item->children()->visible()->count() == 0): echo ''; endif; ?>
    <?php if ($item->grandChildren()->visible()->count() != 0):?>
      <ul class="dropdown-menu grande">
        <?php foreach($item->grandChildren() as $figlio): ?>
          <?php if($figlio->isVisible()):?><li><a href="<?= $item->url() ?>#<?php echo $figlio->uid();?>" class="dropdown-item grande"><?= $figlio->title()->html();?></a></li>
          <?php else:?>
            <li><a href="<?= $figlio->url() ?>" class="dropdown-item grande"><?= $figlio->title()->html();?></a></li><?php endif;?>
        <?php endforeach; ?>
      </ul><?php endif; ?>

<?php endforeach ?>

Are you using Kirby 3?

This is not a problem of the PHP code or Kirby related but a problem of your styles. Use dev tools to inspect your source code and CSS.

Versione del Toolkit: 2.5.12
Versione di Kirby: 2.5.12
Versione del Panel: 2.5.12

Do you see the items when you inspect your code in the browser’ devtools?

yes. however my site is

@texnixe is right. There’s a problem with your styling (CSS).

See for yourself by removing the dropdown-menu grande-classes from your <ul>.

okey but I need the dropdown-menu class, so how can I solve it?

I’m very sorry to have to say that, but we are here to help you get going with Kirby, but we cannot possibly debug your styling or JavaScript issues.

1 Like