yiisoft / yii-bootstrap5

Yii Framework Bootstrap 5 support
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
60 stars 20 forks source link

Allow posible mark the `Home` page as active in `Nav:::class`. #82

Closed terabytesoftw closed 2 years ago

terabytesoftw commented 2 years ago
Q A
Is bugfix? ✔️
New feature?
Breaks BC?
albertborsos commented 2 years ago

Thanks for this fast fix, but it is still not the way what I expect.

Here is the case I would like to use:

my Nav widget is:

Nav::widget()
    ->currentPath('/home')
    ->homeLink('/home')
    ->items([
          [
              'label' => 'Home',
              'url' => '/home',
          ],
          [
              'label' => 'Item1',
              'url' => '/item1',
          ],
      ])
      ->render()

I expect that the first element in items is marked with active class.

terabytesoftw commented 2 years ago

Thanks for this fast fix, but it is still not the way what I expect.

Here is the case I would like to use:

my Nav widget is:

Nav::widget()
    ->currentPath('/home')
    ->homeLink('/home')
    ->items([
          [
              'label' => 'Home',
              'url' => '/home',
          ],
          [
              'label' => 'Item1',
              'url' => '/item1',
          ],
      ])
      ->render()

I expect that the first element in items is marked with active class.

You can now mark the first menu item as active, like this at https://getbootstrap.com/docs/5.1/components/navbar/#supported-content

Nav::widget()
     ->currentPath('/home')
     ->items([
           [
               'label' => 'Home',
               'url' => '/home',
           ],
           [
               'label' => 'Item1',
               'url' => '/item1',
           ],
       ])
       ->render()
vjik commented 2 years ago

May be add option doNotMarkActive(string ...$link) ?

In some cases we don't need mark home link as active.

terabytesoftw commented 2 years ago

¿Se puede agregar la opción?doNotMarkActive(string ...$link)

En algunos casos, no necesitamos marcar el enlace de inicio como activo.

¿Se puede agregar la opción?doNotMarkActive(string ...$link)

En algunos casos, no necesitamos marcar el enlace de inicio como activo.

Nav::widget()
     ->currentPath('/home')
     ->items([
           [
               'label' => 'Home',
               'url' => '/home',
               'active' => false,
           ],
           [
               'label' => 'Item1',
               'url' => '/item1',
           ],
       ])
       ->render()