What's the best way to customize / add pages to the admin generator?

I'm using Symfony 1.4 and Doctrine.

My application's backend was built using Symfony's admin generator. It works great when I want to display basic stuff.

But tehre's not a lot of documentation on how to enhance it and add new pages.

Let's take an example: I want to list published items on one page and to-be-published items on another one. I've used several ways to that in my application but can't figure out what the best way is:

  • playing with filters and then modify templates depending on where you are?
  • creating another module calling a different table_method?
  • some other technique I don't know about?

What's the best practice here? How do you guys usually do to customize your admin?

Answers


Shameless self-promotion here. I wrote up a blog post this week on customising the admin generator - one of the things I did was to add new pages etc into the generator. The way I did it is probably a bit hardcore, but it works nicely :-)

The best place to start looking is the auto-generated actions class for your module and extending it in your app/module/actions/actions.class.php file. In particular, the index action which sets up the ORM pager. You should be able to use any query from your ORM to supply your ORM pager with data - in cases where I've needed to alter it, I use a Doctrine query generated in the same way as normal to pass to the pager. This means that I can customise what fields are displayed, including ones from other tables joined in etc in a single query. This is your 'table method' mentioned above.

Filters will work just as well - it depends on your use case and whether filters are appropriate, particularly for display. If you want a /showpublisheditems page, then I'd go with a new action and the new query for the pager. If you want on-the-fly customisation, then go with the filter option.

The filter docs I thought were a bit lacking in places too - quick tip, they look for a addYourColumnNameColumnQuery() method in your top-level filter class (lib/filter/...) which takes a query passed in and uses eg addWhere("x.column_name = ?", $foo) to the query passed in.

Bleh :-) sorry, that was a bit of a brain dump, but hopefully it helps! :-)


Need Your Help

Change the background color in my HTML code through JavaScript

javascript html css

New to JavaScript and HTML. I'm trying to change the background color in my HTML code through JavaScript.

Meteor: access template helpers inside an each statement

html meteor spacebars

So if I have a template and I have some helpers defined for that template, I can use them normally within the template, but if I try to use them inside an {{#each whatever}} it gives me an error. See