2017 © Pedro Peláez
 

symfony-bundle flob-foundation-bundle

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

image

florianbelhomme/flob-foundation-bundle

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  • Saturday, February 10, 2018
  • by florianbelhomme
  • Repository
  • 6 Watchers
  • 49 Stars
  • 12,573 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 13 Forks
  • 1 Open issues
  • 14 Versions
  • 6 % Grown

The README.md

Flob Foundation Bundle

Total Downloads Latest Stable Version Build Status SensioLabsInsight License, (*1)

About

DISCONTINUED, (*2)

This bundle integrates the features of the responsive framework Foundation, from ZURB (thanks guys), into Symfony by providing templates, Twig extensions, services and commands. You can quickly setup a responsive theme for an interface for your project. It will have the "look'n'feel", the responsiveness and the simplicity of Foundation., (*3)

BE AWARE: THIS BUNDLE WILL NOT ADD THE FOUNDATION FRAMEWORK BUT RATHER FEATURES FOR SYMFONY TO WORK WITH IT, (*4)

Demo available here., (*5)

Requirements

This bundle will theme for you elements of : - the KnpMenuBundle to manage menu or sidebar. - the KpnPaginatorBundle for pagination. - the WhiteOctoberPagerfantaBundle for pagination based on Pager Fanta., (*6)

Installation and configuration

composer require florianbelhomme/flob-foundation-bundle

Then, edit your app/AppKernel.php and add:, (*7)

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new Flob\Bundle\FoundationBundle\FlobFoundationBundle(),
            ...
        ];
    }
}

You now need to add the libraries to your project., (*8)

The easy way to do it (but there are other ways to do so):, (*9)

<html>
    <head>
        ...
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/normalize.min.css" type="text/css" />
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.min.css" type="text/css" />
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" type="text/css" />
        <link rel="stylesheet" href="{{ asset('bundles/flobfoundation/css/foundationtosymfony.css') }}" type="text/css" />
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
        ...
    </head>
    <body>
        ...
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation.min.js"></script>
        <script type="text/javascript" src="{{ asset('bundles/flobfoundation/js/foundationtosymfony.js') }}"></script>
    </body>
</html>

Your project is ready!, (*10)

Configuration

This bundle does not theme any elements by default, in case you want to use Foundation on a specific form or bundle., (*11)

To automatically theme forms or other elements by default, go into the app/config/config.yml and add at the end:, (*12)

flob_foundation:
    theme: { form: true, knp_menu: true, knp_paginator: true, pagerfanta: true }

If you want to do specific HTML markup that extends templates of this bundle: * create your template in your bundle * add {% extends 'FlobFoundationBundle:Form:foundation_form_div_layout.html.twig' %} at the top (the form template, for example) * edit the app/config/config.yml:, (*13)

flob_foundation:
    theme: { form: true, knp_menu: true, knp_paginator: true, pagerfanta: true }
    template:
        form: 'YourBundle:YourFolder:formtemplate.html.twig'
        breadcrumb: 'YourBundle:YourFolder:breadcrumbtemplate.html.twig'
        knp_menu: 'YourBundle:YourFolder:menutemplate.html.twig'
        knp_paginator: 'YourBundle:YourFolder:paginatortemplate.html.twig'
        pagerfanta: 'YourPagerFantaTemplate'

Usage

Theme

However instead of setting it in the configuration, you can theme specific elements using one of these methods:, (*14)

{# Form #}
{% form_theme yourform 'FlobFoundationBundle:Form:foundation_form_div_layout.html.twig' %}

{# Menu #}
{{ knp_menu_render('yourmenu', {'template' : 'FlobFoundationBundle:Menu:foundation_knp_menu.html.twig'}) }}

{# Pagination with KNP paginator #}
{{ knp_pagination_render(yourpagination, 'FlobFoundationBundle:Pagination:foundation_sliding.html.twig') }}

{# Pagination with PagerFanta (through WhiteOctober bundle) #}
{{ pagerfanta(paginationFanta, 'foundation') }}

Top bar

To create a top bar, just create your KNP Menu, add a route to the root element and set extra options:, (*15)

$menu = $this->factory->createItem(
    'My website',
    [
        'route' => 'homepage',
        'extras' => ['menu_type' => 'topbar']
    ]
);

You can add an icon before, after or instead of the label. By default the icon will be added before the label. The icon must be the name of one of Font-Awesome, example : "fa-bell-o"., (*16)

$menu->addChild(
    "Entry",
    [
        'route' => 'route_entry',
        'extras' => [
            'icon' => 'fa-bell-o',
            'icon_position' => 'no-label' # can be 'before', 'after' or 'no-label'
        ]
    ]
);

If you want a breadcrumb generated from a KNP Menu add this code in your template :, (*17)

{{ flob_foundation_breadcrumb_render('yourknpmenu') }}

If you want a specific template :, (*18)

{{ flob_foundation_breadcrumb_render('yourknpmenu', {'template' : 'YourBundle:YourFolder:breadcrumbtemplate.html.twig') }}

Slider (form field type)

You can now use the slider in your forms., (*19)

The slider extend the number field type, so it has the same options. The additional options are : * start : type: integer / default: 0 This specifies the starting point number. * end : type: integer / default: 100 This specifies the highest number in the range. * step : type: integer / default: 1 This specifies the cursor's incremental skip. * vertical : type: boolean / default: false If true, displays the slider vertically instead of horizontally., (*20)

This is an example of the field :, (*21)

$builder->add('My slider', 'slider', ['label' => 'Slider', 'start' => 10, 'end' => 20, 'step' => 2]);

Switch (form field type)

You can now use the switch in your forms., (*22)

The switch extend the choice field type, so it have the same options. But you can't set the option "expanded" to false (cannot be a select)., (*23)

This is an example of the field :, (*24)

$builder->add('switch_radio', 'switch', ['label' => 'Switch (as radio)', 'choices' => [1 => 'Choice 1', 2 => 'Choice 2', 3 => 'Obi wan kenobi'], 'multiple' => false]);

Button Group (form field type)

You can now use button groups in your forms., (*25)

Button groups are button, grouped together by Foundation. This way they are rendered on the same line, instead of all on a different row., (*26)

This is an example of the field :, (*27)

$builder->add(
    'buttons',
    'button_group',
    [
        'label' => 'Buttons group',
        'buttons' => [
            'back' => [
                'type'    => 'button',
                'options' => [
                    'label' => 'Cancel',
                    'attr' => [
                        'class' => 'secondary',
                    ],
                ],
            ],
            'save' => [
                'type'    => 'submit',
                'options' => [
                    'label' => 'Submit',
                ],
            ],
        ],
        'attr' => [
            'class' => 'right',
        ],
    ]
);

In the buttons array, you define the buttons that need to be rendered. All the buttons should be of FormType ButtonType. For the ButtonType, you cannot specify behavior in Symfony. You can change the type to reset , to render a button with type="reset", (a ResetType) but cannot add links., (*28)

However, you have various options: * add an onClick tag to the attr array * add a class link, a tag data-url to the attr array and let JavaScript handle it, (*29)

Button Bar (form field type)

A button bar is a group of button groups, perfect for situations where you want groups of actions that are all related to a similar element or page., (*30)

This is an (long :D) example of the field :, (*31)

$builder->add(
    'button_bar',
    'button_bar',
    [
        'button_groups' => [
            'button_group_first' => [
                'label' => 'Buttons group',
                'buttons' => [
                    'one' => [
                        'type'    => 'submit',
                        'options' => [
                            'label' => 'one',
                        ],
                    ],
                    'two' => [
                        'type'    => 'button',
                        'options' => [
                            'label' => 'two',
                            'attr' => [
                                'class' => 'success',
                            ],
                        ],
                    ],
                    'three' => [
                        'type'    => 'button',
                        'options' => [
                            'label' => 'three',
                            'attr' => [
                                'class' => 'alert',
                            ],
                        ],
                    ],
                ],
                'attr' => [
                    'class' => 'round',
                ],
            ],
            'button_group_second' => [
                'label' => 'Buttons group',
                'buttons' => [
                    'four' => [
                        'type'    => 'button',
                        'options' => [
                            'label' => 'four',
                            'attr' => [
                                'class' => 'disabled',
                            ],
                        ],
                    ],
                    'five' => [
                        'type'    => 'button',
                        'options' => [
                            'label' => 'five',
                            'attr' => [
                                'class' => 'secondary',
                            ],
                        ],
                    ],
                    'six' => [
                        'type'    => 'button',
                        'options' => [
                            'label' => 'six',
                            'attr' => [
                                'class' => 'secondary',
                            ],
                        ],
                    ],
                ],
                'attr' => [
                    'class' => 'radius',
                ],
            ],
        ],
    );

Authors

Contribute

Contributions to the package are always welcome! Feedback is great., (*32)

Feel free to fork the project and make a PR. You can also help the others, look in the issues., (*33)

Support

If you are having problems, fill an issue., (*34)

License

This bundle is licensed under the MIT License, (*35)

The Versions

10/02 2018

dev-master

9999999-dev

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

27/10 2016

3.0.2

3.0.2.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

26/08 2016

dev-moving-foundation-6

dev-moving-foundation-6

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

26/08 2016

3.0.1

3.0.1.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

05/01 2016

3.0.0

3.0.0.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

07/08 2015

2.1.0

2.1.0.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

27/06 2015

2.0.2

2.0.2.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

01/03 2015

2.0.1

2.0.1.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

19/02 2015

2.0.0

2.0.0.0

Integrates the features of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony foundation responsive zurb

03/10 2014

1.0.5

1.0.5.0

Integrates the functionnalities of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

bundle symfony foundation responsive zurb

10/07 2014

1.0.4

1.0.4.0

Integrates the functionnalities of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

bundle symfony foundation responsive zurb

08/04 2014

1.0.3

1.0.3.0

Integrates the functionnalities of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

bundle symfony foundation responsive zurb

13/02 2014

1.0.2

1.0.2.0

Integrates the functionnalities of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

bundle symfony foundation responsive zurb

08/01 2014

1.0.1

1.0.1.0

Integrates the functionnalities of the responsive framework Foundation, from Zurb, into Symfony2 by providing templates, Twig extensions, services and commands.

  Sources   Download

MIT

The Requires

 

bundle symfony foundation responsive zurb