nedarta/yii2-extended-navbar 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nedarta/yii2-extended-navbar

最新稳定版本:1.0.1

Composer 安装命令:

composer require nedarta/yii2-extended-navbar

包简介

An extended NavBar widget for Yii2 with support for external items and Bootstrap 5.

README 文档

README

License Packagist Version

A Bootstrap 5-compatible NavBar widget for Yii2 that adds support for external navigation items and enhanced customization options.

Key Features

  • Bootstrap 5 compatibility with modern navbar styling
  • External navigation items that remain visible outside the collapsible section
  • Flexible positioning options for external items (left, right, or before toggle)
  • Support for dynamic dropdowns in both regular and external items
  • Comprehensive customization options for all navbar elements

Installation

composer require nedarta/yii2-extended-navbar

Basic Usage

use nedarta\navbar\ExtendedNavBar;
use yii\helpers\Html;

echo ExtendedNavBar::widget([
    'brandLabel' => 'My Company',
    'brandUrl' => Yii::$app->homeUrl,
    'options' => [
        'class' => 'navbar-expand-lg navbar-light bg-light',
    ],
    'externalItems' => Nav::widget([
        'options' => ['class' => 'navbar-nav ms-auto d-flex flex-row gap-2 me-3'], //configure as needed
        'items' => [
            ['label' => 'EN', 'url' => ['/site/language', 'lang' => 'en']],
            ['label' => 'LV', 'url' => ['/site/language', 'lang' => 'lv']],
        ],
    ]),
]); ?>

<?= Nav::widget([
    'options' => ['class' => 'navbar-nav ms-auto'],
    'items' => [
        ['label' => 'Home', 'url' => ['/site/index']],
        ['label' => 'About', 'url' => ['/site/about']],
        ['label' => 'Contact', 'url' => ['/site/contact']],
    ],
]);

Configuration Options

External Items Structure

Each external item can be:

// Simple link
['label' => 'Home', 'url' => ['/site/index']]

// Dropdown menu
[
    'label' => 'Account',
    'items' => [
        ['label' => 'Profile', 'url' => ['/user/profile']],
        ['label' => 'Settings', 'url' => ['/user/settings']],
        '<hr class="dropdown-divider">',
        ['label' => 'Logout', 'url' => ['/site/logout']],
    ],
]

// Custom HTML
Html::tag('li', 
    Html::a('<i class="fas fa-user"></i>', ['/profile'], ['class' => 'nav-link']), 
    ['class' => 'nav-item']
)

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

  • Create an issue in the GitHub repository
  • Contact the maintainer at GitHub

Developed with ❤️ by Edgars Karlsons (nedarta)

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-06