IML sfAdminList

IML sfAdminList

The admin generator for Symfony 1.4.x integrated with the DataTables jQuery plugin.

  • Language: PHP
    Framework: Symfony
  • Released: Apr 25, 2011
    Last Update: Apr 24, 2011

This package integrates the Symfony 1.4.x Admin generator with a javascript plugin to display large lists of data without using the raw pagination given by default.

It allows to avoid reloading the page every time you go to next/previous page, managing data display through one of the best plugins to load and show table data: DataTables.

Hide

Documentation

Package file

The package file contains three folders, following the tree structure of a default Symfony 1.4.x installation.

The folders are:

  • apps/
  • data/
  • web/

apps/

apps/ contains a couple of examples on how you are able to customize my package. There are two modules: state and city, which are those of the demo page.

By defining the javascript function extend_dataTable() you are able to completely customize the DataTables plugin.

data/

It contains the admin generator to be installed to your Symfony project.

web/

It contains come css and the javascript files to be included.

How it works

When using this admin generator theme, the raw list provided by Symfony library is changed into a table powered by the DataTables plugin.

More deeply, in the file /data/generator/sfDoctrineModule/adminiml/template/list.php is contained the javascript function to initialize the table representing your data to display, converting it into a smart javascript table with quick and non-reloading pagination.

Hide

Installation

Follow this procedure to install the package:

1. Extract the compressed file

You will find 3 folders in it:

  • apps/
  • data/
  • web/

2. Install the admin generator (theme)

This guide starts from a working installation of Symfony 1.4.x. If You don't have already created your project, please refer to Symfony documentation.

Copy the content of the extracted data/ folder into the data/ folder of your Symfony project.

The name of the new admin generator is admin_iml. The installation of the admin generator is that simple, from now on you will be able to use it in any admin Symfony module of your project.

3. Install DataTables jQuery plugin

Copy the file jquery.dataTables.min.js contained in the web/js/ directory of the package in the js/ folder of your Symfony project. You can also download the latest version of this plugin from here.

As it requires jQuery to work, copy the file jquery-1.5.2.min.js contained in the web/js/ directory of the package in the js/ folder of your Symfony project if not already included.

Optionally copy the files admin_iml.css and sfadminoverwrite.css contained in the web/css/ directory of the package in the css/ folder of your Symfony project. The first is the default css of the plugin with small modifications and the second is made by me to correct some layout errors.

4. Use the new admin generator

Make your admin generator configuration file (generator.yml) look like this:

generator:
  class: sfDoctrineGenerator
  param:
    model_class:           City
    theme:                 admin_iml
    non_verbose_templates: true
    with_show:             false
    singular:              City
    plural:                cities
    route_prefix:          city
    with_doctrine_route:   true
    actions_base_class:    sfActions

    config:
      actions: ~
      fields:  ~

      list:
        max_per_page: 1000000
        batch_actions: []
      filter:  ~
      form:    ~
      edit:    ~
      new:     ~

The most important things are:

theme: admin_iml

to use the new admin generator theme

max_per_page: 1000000

to load all data at once

batch_actions: []

to prevent batch actions. You can enable batch actions, but it will work only on the records displayed at the moment, and not on the entire collection of data.

Don't forget to clean the cache every time you will made changes to the admin generator, and also right now after the first installation. php symfony cc

5. (Optionally) Customize the plugin settings

By default the plugin is initialized in this way:

  • pagination with full numbers
  • showing 15 rows
  • sorting the table through the first column (index 0) in ascending order

Of course you can completely customize the plugin behavior, and moreover you can make it without modifying the admin generator.

The only thing you have to do is define a javascript function called

extend_dataTable(oTable)

and put all your customizations into it. In the function you have at your disposal the variable oTable, which is the javascript object created when the plugin was called. Just look at the plugin documentation, you don't need nothing else!

Create a file called listheader.php in the template/ directory of your module. You can give a look to the apps/frontend/module/ folder of the package for a couple of examples.

This is a sample of the function __extenddataTable(oTable)___:

You're done!

You need to log-in or create an account
  • Create an account
  • Log-in
Please use your real name.
Activation link will be sent to this address.
Minimum 8 characters
Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

X

Save your watchlist

Fill your details below to receive project updates from your watch list - including new versions, price changes and discounts.

I agree to the terms of use and privacy policy.

1 license From » $7.99 14 day money-back guarantee View Licenses
or Get a quote

for customization or integration services

Post a comment

Or enter your name and Email
No comments have been posted yet.