idci/nav-bar-bundle

Symfony NavBarBundle

安装次数: 4,658

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 10

分支: 0

公开问题: 0

类型:symfony-bundle

v1.0.0 2017-03-08 16:04 UTC

This package is auto-updated.

Last update: 2024-09-24 20:19:47 UTC


README

Symfony2 插件,用于管理导航栏

安装

要安装此插件,请按照以下步骤操作

首先,在您的 composer.json 文件中添加依赖项

"require": {
    ...
    "idci/nav-bar-bundle": "dev-master"
},

然后使用以下命令安装插件

$ php composer update

在您的应用程序内核中启用插件

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new IDCI\Bundle\NavBarBundle\IDCINavBarBundle()
    );
}

更新您的 routing.yml 文件

idci_nav_bar:
    resource: "@IDCINavBarBundle/Controller/"
    type:     annotation

配置

此插件提供了一种简单易定制的导航栏。要配置它,只需在 app/config/config.yml 中更改或添加项目。

# Tms navbar configuration
idci_nav_bar:
    brand_title: "MyNAV"
    brand_url: http://www.mywebsite.com
    items:
        link1:
            title: LinkTitle1
            url: http://www.website1.com
            color: "#F00"
        link2:
            title: LinkTitle2
            url: http://www.website2.com
            color: "#00F"
        linkN:
            title: LinkTitleN
            url: http://www.websiteN.com
            color: "#000"
            target: _blank

路由

要查看路由,运行以下命令

$ php app/console router:debug --env=prod

您将得到以下输出

[router] Current routes
Name                   Method Scheme Host Path
idci_navbar_menu_nav ANY    ANY    ANY  /nav.{_format}

配置的菜单现在可以通过 HTTP 协议以不同格式访问。要查看其实际效果,只需在浏览器中打开之前配置的虚拟主机(navbar.ens-lyon.fr),并添加以下路径:/nav.{_format}

例如: http://www.mywebsite.com/nav.html

以下是可用的格式列表

* html => This will display the menu
* css  => This is the generated css
* json => This is the menu data in Json format
* js   => This is the generated js to inject the menu in web page

如何使用

使用此应用程序的方法有很多,以下是一些方法,但根据您的想象力,还有其他可能的方法。

JavaScript

简单地将 JavaScript 源代码添加到现有网站中,以自动注入 HTML 和 CSS 数据,以显示此菜单。

<!DOCTYPE html>
<html>
    <head>
        ...
        <script type="text/javascript" src="http://www.mywebsite.com/nav.js"></script>
    </head>
    <body>
        ...
    </body>
</html>