# Menu dropdown question

**URL:** <https://forum.getkirby.com/t/menu-dropdown-question/14495>\
**Category:** Questions\
**Tags:** v3\
**Created:** [June 5, 2019, 3:01pm UTC](https://forum.getkirby.com/t/menu-dropdown-question/14495 "2019-06-05T15:01:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![portobien](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/portobien/32/7162_2.png) [@portobien](https://forum.getkirby.com/u/portobien)\
**Post date:** [June 5, 2019, 3:01pm UTC](https://forum.getkirby.com/t/menu-dropdown-question/14495/1 "2019-06-05T15:01:02Z")

</div>

Hi everyone,

I am struggling with the following:

I made a menu and it almost works.

```
  <ul class="menu">
    <?php foreach($pages->visible() as $p): ?>
    <li>
      <a class="al has-dropdown <?php e($p->isOpen(), ' active') ?>" href="<?php echo $p->url() ?>"><?php echo $p->title()->html() ?></a>

      <?php if($p->hasVisibleChildren()): ?>
      <ul class="submenu ">
        <?php foreach($p->children()->visible() as $p): ?>
        <li>
          <a href="<?php echo $p->url() ?>" class="al <?php e($p->isOpen(), ' active') ?>"><?php echo $p->title()->html() ?></a>
        </li>
        <?php endforeach ?>
        <div class="cf"></div>
      </ul>
      <?php endif ?>

    </li>
    <?php endforeach ?>
  </ul>

```

The problem now is that every menu item a dropdown sign has even when there is no submenu. I know this has to do with the: “has-dropdown” class but can’t get it working. Can anybody help me?

Thanks!

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [June 5, 2019, 3:06pm UTC](https://forum.getkirby.com/t/menu-dropdown-question/14495/2 "2019-06-05T15:06:37Z")

</div>

> [@portobien](#):
>
> \<?php if($p-\>hasVisibleChildren()): ?\>

You probably need to do the same trick as the active class, but instead test for children…

```auto
<?php e($p->hasVisibleChildren(), ' has-dropdown') ?>

```

So that line becomes

```auto
<a class="al <?php e($p->hasVisibleChildren(), ' has-dropdown') ?> <?php e($p->isOpen(), ' active') ?>" href="<?php echo $p->url() ?>"><?php echo $p->title()->html() ?></a>
```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 5, 2019, 3:08pm UTC](https://forum.getkirby.com/t/menu-dropdown-question/14495/3 "2019-06-05T15:08:13Z")

</div>

On a side note (unrelated to your problem), you should probably update all references to `visible/invisible` etc with `listed/unlisted`, since `visible` etc. was deprecated in Kirby 3.

---

<div class="post-metadata">

**Author:** ![portobien](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/portobien/32/7162_2.png) [@portobien](https://forum.getkirby.com/u/portobien)\
**Post date:** [June 5, 2019, 3:13pm UTC](https://forum.getkirby.com/t/menu-dropdown-question/14495/4 "2019-06-05T15:13:22Z")

</div>

> [@jimbobrjames](#):
>
> ```auto
> <a class="al <?php e($p->hasVisibleChildren(), ' has-dropdown') ?> <?php e($p->isOpen(), ' active') ?>" href="<?php echo $p->url() ?>"><?php echo $p->title()->html() ?></a>
> 
> ```

Hi @jimbobrjames thank you for your help!

---

<div class="post-metadata">

**Author:** ![portobien](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/portobien/32/7162_2.png) [@portobien](https://forum.getkirby.com/u/portobien)\
**Post date:** [June 5, 2019, 3:13pm UTC](https://forum.getkirby.com/t/menu-dropdown-question/14495/5 "2019-06-05T15:13:49Z")

</div>

I’ll change al references. Thank you!
