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
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 contents:
Tweaked tasks
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.
A layout
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.
Tree Helper
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.
Wrapping Up
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.
Bake on!











So, I'm commenting before reading the article, but trust me, the article is definitely going to be read. Upon seeing my last name I was like, holy moly, my name is showing up in this post! How is that happening. Than I remembered our IRC chat ... Ad7Six's posts are my Christmas morning presents!
Hey, your idea sounds good. Gonna give it a try today.
Some install instructions would be great. After making some assumptions and trying a few things. I am still not getting it to work properly.
Asumeing that I cake bake normally 3 times (for skel (with ur app folder added), database, and a Model), then create an empty controller for that model, I then run 'cake bake_admin apples' and get my admin views. It didnt find the views however..
I'm not sure what install instructions would be useful; you need to know how to run console tasks to be able to run a specific console task, and the zip file is a "paste over" zip for an existing install. You put the vendor files in the vendor folder, and the app files in the app folder of an existing install (if you want to use them at all that is. You can read specifically about the bake admin script on the bakry.