Happy Christmas leveille!
How would you like to be able to generate your entire admin backend in one call? Not
interesting enough? How about with built in index filters and by writing practically
no code? Well... keep reading then :).
The code I am discussing here is available from the Noswad cakeforge project.
Be sure to read the release note.
What's in the new download?
There are a few supporting files in the download - Bake templates themselves obviously have no
dependencies, however the example code my templates generate do so they are included to
hopefully demonstrate/inspire how to get the most out of custom templates and bake. So, the
The controller task has been modified only to prevent the inclusion of the helpers var (with
the included app controller file, no code at all is required in controllers by default), the
view task has been modified to pass the schema data to the view template to allow some
fine-tunning based on field types. There's a
ticket requesting this change.
Yeah how exciting :). A default admin layout is included in the download to allow the
downloaded files to work out of the box.
JS and CSS files
A small amount of jquery is used in displaying and hiding the filter form - there's also a
default admin css included.
Although not strictly necessary the admin menu is generated via the Tree Helper.
Filtering element and controller logic
This is the bit that I assume will get some interest and hope will stop "pagination and
filtering" coming up on the google group.
Included in the previously released (v0.1) bake templates was the possibility to zero-in on
data applying PRG style filters by clicking on the values in the table to limit the
results for that column to a specific value. For small and evenly distributed result sets this
works well; if you are looking at your blog listings and see the last 20 posts, which includes
at least one post by each of John, Bob, and Gerald you can click on Bob's name to see the last
20 posts by Bob only. Then, if you want to see only posts in category "Boat" you click on
category "Boat" and see the last 20 posts by Bob, in category Boat - and on you can go until
your filter is as long as you like. However, what happens when you have massive datasets and
complex filtering requirements - where filtering your result sets is not a nice-to-have but a
necessity? How can you (or a user) easily apply a filter to find the 3 Widgets of type x, when
there are thousands of entries in the database and none of them are in the initial index to be
clicked upon? How do you find all posts for the months of January and February? Or all products
more than 10$..?
Well, I guess the answer is obvious: a filter form. So in addition to the table-cell PRG style links
for fine tuning if required, the new bake templates add a filter form to all index pages.
Bake is awesome. running bake and getting all admin views in a single console call is
awesome-er, running bake and getting pretty much a fully working admin backend in a single call
is still more awesome, making a db change, running bake and getting a fully functional admin
backend with which you (typically) only need to comment out the few things you don't need to be
done is awesome-est :). The results of the new bake templates may still need some tweaking so
as I'm in agreement with a previous commenter this
cake goodie goes out here on the blog.