fvchs/sonata-ajax-block-bundle

Adds ajax functionality to the sonata block bundle.

Installs: 4 876

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

dev-master / 0.0.1.x-dev 2017-02-21 14:08 UTC

This package is not auto-updated.

Last update: 2024-04-13 17:46:39 UTC


README

Work in Progress.

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require fvchs/sonata-ajax-block-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Fvchs\SonataAjaxBlockBundle\FvchsSonataAjaxBlockBundle(),
        );

        // ...
    }

    // ...
}

Configuration

  • Replace the sonata.block.renderer to enable ajax loading

      # app/config/sonata_block.yml
      
      services:
          sonata.block.renderer: '@fvchs.sonata_ajax_block.renderer'
    
  • Add this to your routing configuration

      #  app/config/routing.yml
      
      fvchs_sonata_ajax_block:
          resource: "@FvchsSonataAjaxBlockBundle/Resources/config/routing.yml"
          prefix:   /
    
  • Mark Blocks with the ajax attribute

      # app/config/sonata_admin.yml
      
      sonata_admin:
          dashboard:
              blocks:
                  - { type: my.block.one, settings: { attr: [ajax: true] } }
                  - { type: my.block.two }
    

    The first block in this example will be lazy loaded via ajax. The second block will stay static.