PHPackages                             it-blaster/page-layout-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. it-blaster/page-layout-bundle

ActiveSymfony-bundle

it-blaster/page-layout-bundle
=============================

Bootstrap page layout for sonata, based on gridstack.js

514.6k↓100%1CSS

Since May 31Pushed 8y ago10 watchersCompare

[ Source](https://github.com/it-blaster/page-layout-bundle)[ Packagist](https://packagist.org/packages/it-blaster/page-layout-bundle)[ RSS](/packages/it-blaster-page-layout-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PageLayoutBundle
================

[](#pagelayoutbundle)

Bootstrap page layout for Symfony [Sonata Admin Bundle](https://github.com/sonata-project/SonataAdminBundle), based on [gridstack.js](https://github.com/troolee/gridstack.js)

Preview
-------

[](#preview)

### Simple editor in Sonata Admin

[](#simple-editor-in-sonata-admin)

[![Resize and drag blocks](./Resources/public/example_imgs/1.png)](./Resources/public/example_imgs/1.png)[![Simple edit](./Resources/public/example_imgs/2.png)](./Resources/public/example_imgs/2.png)[![Easy change any properties](./Resources/public/example_imgs/3.png)](./Resources/public/example_imgs/3.png)

### Bootstrap grid as result

[](#bootstrap-grid-as-result)

[![Bootstrap grid as result](./Resources/public/example_imgs/result.png)](./Resources/public/example_imgs/result.png)

Installation
------------

[](#installation)

### With Composer

[](#with-composer)

```
composer require it-blaster/page-layout-bundle
```

### Add post install/update script to `composer.json`

[](#add-post-installupdate-script-to-composerjson)

`installGridStackJs` just make system call `bower install` in bundle's directory

```
{
    "scripts": {
        "post-install-cmd": [
             "Etfostra\\PageLayoutBundle\\Composer\\ScriptHandler::installGridStackJs",
            ...
        ],
        "post-update-cmd": [
             "Etfostra\\PageLayoutBundle\\Composer\\ScriptHandler::installGridStackJs",
            ...
        ]
    }
}
```

### Register the bundle in your `AppKernel.php`

[](#register-the-bundle-in-your-appkernelphp)

```
...
new Etfostra\PageLayoutBundle\EtfostraPageLayoutBundle(),
...
```

### Edit `config.yml`

[](#edit-configyml)

Add `EtfostraPageLayoutBundle` to `assetic.bundles`

```
assetic:
    ...
    bundles:
        ...
        - EtfostraPageLayoutBundle
```

Configuration
-------------

[](#configuration)

All configs are optional, default values present below, `config.yml`:

```
etfostra_page_layout:
    grid_settings: # https://github.com/troolee/gridstack.js#options
        always_show_resize_handle: false
        animate: true
        auto: true
        cell_height: 80
        draggable:
            handle: '.grid-stack-item-content'
            scroll: true
            appendTo: 'body'
        handle: '.grid-stack-item-content'
        handle_class: ''
        height: 0
        float: false # http://troolee.github.io/gridstack.js/demo/float.html
        item_class: 'grid-stack-item'
        min_width: 768
        placeholder_class: 'grid-stack-placeholder'
        placeholder_text: ''
        resizable:
            autoHide: true
            handles: 'se'
        static_grid: false
        vertical_margin: 10
        width: 12
        item_min_width: 4
    properties: # data for generating additional widget properties (options in select)
        media_size_prefix:
            xs: XS — Extra small devices
            sm: SM — Small devices Tablets
            md: MD — Medium devices Desktops
            lg: LG — Large devices Desktops
    templates:
        front_layout: EtfostraPageLayoutBundle:Frontend:page_layout.html.twig
```

Using
-----

[](#using)

### Insert `page_layout` field in Sonata Admin class

[](#insert-page_layout-field-in-sonata-admin-class)

```
class YourAdmin extends Admin
{
    ...
    protected function configureFormFields(FormMapper $formMapper)
    {
        ...
        $formMapper
            ->add('your_text_field', 'page_layout', array(
                'required' => false,
                'choices'  => array(
                    // Key and value can be any string, it's up to you.
                    // This keys will be available later in WidgetRenderer::setWidgets
                    'CurrentPage:'          => 'Current page content',
                    'Widget:feedbackform'   => 'Feedback form',
                    'Widget:leftmenu'       => 'Left menu',
                ),
            ))
        ...
    }
```

From now, you can edit and save (to `your_text_field`) data of grid in Sonata Admin.

### Frontend layout generation

[](#frontend-layout-generation)

For layout generation we must call and configure `etfostra_page_layout.services.page_layout` service form controller

```
$layout = $this->get('etfostra_page_layout.services.page_layout')
    ->setLayoutData( $your_text_field )
    ->setWidgetRenderer( $renderer )
    ->render();
```

But now we have two undefined variables! It's ok, how to define it:

```
$your_text_field = $yourObject->getYourTextField(); // It's simple, this is data from your your_text_field, that we edit in Sonata Admin
$renderer = $this->get('widget_renderer'); // This is more complex, we must implement our service widget_renderer
```

Define this new service in `services.yml`, arguments are optional and depends on realization

```
services:
    ...
    widget_renderer:
        class: Your\AppBundle\Service\WidgetRenderer
        arguments:
            - @templating
```

Time to create our new renderer service, call it `WidgetRenderer`

```
namespace Your\AppBundle\Service;

use Etfostra\PageLayoutBundle\Services\WidgetRenderInterface;
use Symfony\Component\Templating\EngineInterface;

class WidgetRenderer implements WidgetRenderInterface
{
    protected $widgets;
    protected $templating;

    public function __construct(EngineInterface $templating)
    {
        $this->templating = $templating;
    }

    /**
     * At this we must fill $this->widgets array with html rendered widgets
     */
    public function setWidgets(array $widgets) // $widgets example: array('CurrentPage:', 'Widget:feedbackform', 'Widget:leftmenu')
    {
        foreach ($widgets as $widget_id) {
            $this->widgets[$widget_id] = $this->templating->render('YourAppBundle:Widget:widget.html.twig', array(
                'widget_id' => $widget_id,
            ));
        }
    }

    public function getWidget($widget_id)
    {
        if (isset($this->widgets[$widget_id])) {
            return $this->widgets[$widget_id];
        }

        return null;
    }
}
```

It's very simplified example, you can create more complex realization, depends on your widget system.

###  Health Score

27

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7cc8131cda74637bde62ed29751e18ec9472feef0c419861c3cf44877a32e3b4?d=identicon)[etfostra](/maintainers/etfostra)

---

Top Contributors

[![etfostra](https://avatars.githubusercontent.com/u/11174226?v=4)](https://github.com/etfostra "etfostra (14 commits)")[![antonsmolin](https://avatars.githubusercontent.com/u/9770065?v=4)](https://github.com/antonsmolin "antonsmolin (6 commits)")

### Embed Badge

![Health badge](/badges/it-blaster-page-layout-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/it-blaster-page-layout-bundle/health.svg)](https://phpackages.com/packages/it-blaster-page-layout-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
