skillberto/menu-bundle

This bundle generate menu with from admin with KnpMenuBundle, SonataAdminBundle, and optional SkillbertoAdminBundle

2.2.2 2014-03-02 20:31 UTC

README

This bundle creates Menu into the template with KnpMenuBundle, so this bundle is neccessary. Also use SonataAdminBundle for admin generating. For more admin options include SkillbertoAdminBundle.

You have to download and configure those bundles too.

Installation:

Step1: Download the bundle:

Using Composer: This is the prefered Symfony2 way.

Add the following lines in your composer.json:

{
    ...
    "require": {
        ...
        "skillberto/menu-bundle": "dev-master"
    },
    ...
}

Using Git and deps file:

If you use git, you have to download other bundles too.


[SkillbertoMenuBundle]
    git=https://github.com/skillberto/SkillbertoMenuBundle.git
    target=bundles/Skillberto/MenuBundle

Now, run the vendors script to download the bundle:

$ php bin/vendors install

Using Git Submodules:

If you prefered this way with Git, run this:

$ git submodule add https://github.com/skillberto/SkillbertoMenuBundle.git vendor/bundles/Skillberto/MenuBundle
$ git submodule update --init

Step2: Register the namespaces:

If you installed with composer, use the created autoload.php, and jump to step3, else use the following code:

<?php
// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Skillberto\MenuBundle' => __DIR__.'/../vendor/bundles',
    // ...
));

Step3: Register the bundle:

To start using the bundle, register it in you AppKernel.php:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Skillberto\MenuBundle\SkillbertoMenuBundle(),
    );
    // ...
}

Step4: (optional) Configure the bundle:

The bundle uses Symfony2 DependencyInjection container, but SonataAdmin maybe needs some configuration.

#app/config/config.yml
skillberto_menu:    ~

#if you have blocks and groups in sonata_admin, add the following line to sonata_admin
sonata_admin:
    dashboard:
        groups:
            System: ~

Create your menu!

Create menu:

Go into admin (http://yourdomain/admin/dashboard), after that in the System group, Menu and Add new: (http://yourdomain/admin/skillberto/menu/menu/create)

This bundle uses Symfony2 RouteCollection class in the admin side. At the Route section you find existed routes, but not all. The controller filtered defaults the _..... routes ( dev ) and the the following removed_route too:

//Skillberto/MenuBundle/Admin/MenuAdmin.php

//...
class MenuAdmin extends Admin
{
    protected
            // ...
            $removed_route = array(
                "fos_",
                "admin_",
                "sonata_"
            ),
            // ...
}

If you have SkillbertoAdminBundle, the system automatically adds Activate | Inactivate button into actions.

Rendering menu:

Put the following code into the template:

<div class="menu">
    {{ knp_menu_render('SkillbertoMenuBundle:Builder:mainMenu') }}
</div>