Jon !

Blog personnel de Jon

How to create a new admin-gen theme in symfony 1.2

with 2 comments

As I got yesterday a deep issue in symfony 1.2, I decided to blog about it in english as I hope I will save a lot of time to somebody else. My issue was : « how to create a theme for my admin-gen ? ».

Most of admin-gen user know this piece of code in generator.yml

  class: sfPropelGenerator
      model_class:           BlogArticle
      theme:                 admin
      non_verbose_templates: true
      with_show:             false
      singular:              ~
      plural:                ~
      route_prefix:          article
      with_propel_route:     1

let’s talk in deep about it and especially about the theme param. Just an info, don’t try with_show, it’s not supported in symfony 1.2 ^^ !

First of all, back to the basis, what is init-admin, what is generate-admin ?



Result :



Result :

entrepriseGeneratorConfiguration.class.php      entrepriseGeneratorHelper.class.php

To be honest, the only difference I see between init-admin and generate-admin is generate-admin is more complete :

  • It creates a routing rules.
  • It creates some helpers.

Anyways, they both works the same way as they will inherit from cache/frontend/dev/modules/autoIndividu and cache/frontend/dev/modules/autoEntreprise for the modules apps/frontend/modules/individu and apps/frontend/modules/entreprise.

OK, let’s go. My first advice :

symfony cc is not enough, it only cleans configuration and basic cache, but not the generated code. Then rm -r cache/* is the best way to handle a clean of the cache.

My second advice is :

changing randomly the theme param value will not get far cause no error is thrown if the theme is missing, as reported in the ticket #6287! Then the correct default value are :

  • default is you are using a propel:init-admin.
  • admin is you are using a propel:generate-admin

Now let’s create a new theme from a existing one.

The documentation says :

Customizing the Theme

There are other partials inherited from the framework that can be overridden in the module templates/ folder to match your custom requirements.

The generator templates are cut into small parts that can be overridden independently, and the actions can also be changed one by one.

Which means you can override parts of the template contained in cache/frontend/dev/modules/autoIndividu/template in apps/frontend/modules/individu/template.

However, if you want to override those for several modules in the same way, you should probably create a reusable theme. A theme is a sub-set of templates and actions that can be used by an administration module if specified in the theme value at the beginning of generator.yml. With the default theme, symfony uses the files defined in $sf_symfony_lib_dir/plugins/sfPropelPlugin/data/generator/sfPropelModule/admin/.

That’s true, but only for a module generated with propel:generate-admin (which btw gets as default theme the value admin). Even if it’s works be aware that have to do a full copy of the theme (no override of the default theme).

Here we do :

# move to root of your project
cd root_of_my_symfony_project
# get the generator's data for symfony 1.2.6
svn export data/generator
#you can delete what you don't need
rm -r data/generator/sfPropelForm*

Now you get pretty much everything you need for a theme available in a propel:init-admin generated module, or a propel:generate-admin generated module:

  • If you want to make a theme for a init-admin :
    cp -R generator/sfPropelAdmin/default generator/sfPropelAdmin/mytheme
  • If you want to make a theme for a generate-admin :
    cp -R generator/sfPropelModule/admin generator/sfPropelModule/mytheme

To activate your theme :

  class: sfPropelGenerator
      model_class:           BlogArticle
      theme:                 mytheme
      non_verbose_templates: true
      with_show:             false
      singular:              ~
      plural:                ~
      route_prefix:          article
      with_propel_route:     1

Enjoy the advanced admin-gen customization and feel free to ping me in comments if you need more info or if you see something, you are much welcome 😉


Written by Jonathan

mai 2, 2009 à 4:10

Publié dans en, symfony

Tagged with ,

2 Réponses

Subscribe to comments with RSS.

  1. Sir,

    Great work.Really I am Fan of urs.I know by now u must hav made your own custom theme.knowledge grows further more if shared.can u please send me a zip of that customized theme. I would be really grateful to you.

    waiting for your reply


    sumit kumar

    janvier 11, 2010 at 1:24

    • Thank you,

      We didn’t customized the theme to much, the main axis was it should reflect our database naming convention which are stricter.
      Anyways, you right, knowledge grows further if shared, so a zip is on the way to your mailbox as soon as possible.

      Best regards,


      janvier 11, 2010 at 6:53

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )


Connexion à %s

%d blogueurs aiment cette page :