csDoctrineActAsSortablePlugin - 1.0.1

A plugin that adds sorting functions to model

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source


The csDoctrineActAsSortablePlugin is a symfony plugin that allows use of the doctrine behavior actAsSortable.

This behavior provides methods on your model for setting display order/position.

This plugin also contains images to implement for ordering.


  • Install the plugin

    $ symfony plugin:install csDoctrineActAsSortablePlugin
  • Apply the behavior to your model in your schema file config/doctrine/schema.yml, ie:

      actAs: [Sortable]

    Optionally accepts a UniqueBy attribute which will be used on a model with a one-to-many relationship

        actAs: [Sortable]
        uniqueBy: [parent_id]
  • Rebuild your models and database

    $ symfony doctrine:build-all-reload

    alternatively you could build the models, the sql, then run the sql manually

  • Publish your assets

    $ symfony plugin:publish-assets
  • Clear your cache

    $ symfony cc

Available Record Methods

  • promote

  • demote

  • moveToFirst

  • moveToLast

  • moveToPosition


Available Table Methods

  • sort - accepts the array created by the symfony/prototype sortableElement tag

  • findAllSorted - Accepts sort order (asc, desc)

  • findAllSortedWithParent - accepts the parent column name, the value, and sort order (asc, desc)

    Doctrine::getTable('Model')->findAllSortedWithParent($fk_value, $fk_name, 'ASCENDING');

Example Usage With Admin Generator

  • In your module, edit config/generator.yml, and under list, object actions, add:

      promote:      { name: Promote, action: promote,  icon: sortable/icons/promote.png  }
      demote:       { name: Demote, action: demote,  icon: sortable/icons/demote.png  }
      _edit:        -
      _delete:      -
  • In your module, edit ``, Add the following actions:

    public function executePromote()
    public function executeDemote()